diff options
author | JoramWilander <jwawilander@gmail.com> | 2016-03-11 10:48:43 -0500 |
---|---|---|
committer | JoramWilander <jwawilander@gmail.com> | 2016-03-11 10:48:43 -0500 |
commit | fb9a6c76113e5913d2ad7edb595a05e8567a3e85 (patch) | |
tree | dab8e91d1c294e70054a1fadbb0cdef3e393bb80 /store | |
parent | f7156fdb3a4b5d5c35a5d394047e349f04dd2a10 (diff) | |
download | chat-fb9a6c76113e5913d2ad7edb595a05e8567a3e85.tar.gz chat-fb9a6c76113e5913d2ad7edb595a05e8567a3e85.tar.bz2 chat-fb9a6c76113e5913d2ad7edb595a05e8567a3e85.zip |
Auto-create account if team allows sign-up from login page and oauth account doesn't exist
Diffstat (limited to 'store')
-rw-r--r-- | store/sql_user_store.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/store/sql_user_store.go b/store/sql_user_store.go index 47c6ea61a..cc6829b94 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -4,6 +4,7 @@ package store import ( + "database/sql" "fmt" "github.com/mattermost/platform/model" "github.com/mattermost/platform/utils" @@ -11,7 +12,8 @@ import ( ) const ( - MISSING_ACCOUNT_ERROR = "store.sql_user.missing_account.const" + MISSING_ACCOUNT_ERROR = "store.sql_user.missing_account.const" + MISSING_AUTH_ACCOUNT_ERROR = "store.sql_user.get_by_auth.missing_account.app_error" ) type SqlUserStore struct { @@ -481,8 +483,11 @@ func (us SqlUserStore) GetByAuth(teamId string, authData string, authService str user := model.User{} if err := us.GetReplica().SelectOne(&user, "SELECT * FROM Users WHERE TeamId = :TeamId AND AuthData = :AuthData AND AuthService = :AuthService", map[string]interface{}{"TeamId": teamId, "AuthData": authData, "AuthService": authService}); err != nil { - result.Err = model.NewLocAppError("SqlUserStore.GetByAuth", "store.sql_user.get_by_auth.app_error", - nil, "teamId="+teamId+", authData="+authData+", authService="+authService+", "+err.Error()) + if err == sql.ErrNoRows { + result.Err = model.NewLocAppError("SqlUserStore.GetByAuth", MISSING_AUTH_ACCOUNT_ERROR, nil, "teamId="+teamId+", authData="+authData+", authService="+authService+", "+err.Error()) + } else { + result.Err = model.NewLocAppError("SqlUserStore.GetByAuth", "store.sql_user.get_by_auth.other.app_error", nil, "teamId="+teamId+", authData="+authData+", authService="+authService+", "+err.Error()) + } } result.Data = &user |