diff options
author | JoramWilander <jwawilander@gmail.com> | 2015-07-15 12:48:50 -0400 |
---|---|---|
committer | JoramWilander <jwawilander@gmail.com> | 2015-07-22 08:41:53 -0400 |
commit | c39e95c7cb1ad6e812aa3ce4000b4dfdf214e77e (patch) | |
tree | 78075f919a9efd78ad845c6b0f50511a0a826e43 /store | |
parent | 2fef71da693b5afcc31ccad6be8790da8a70817f (diff) | |
download | chat-c39e95c7cb1ad6e812aa3ce4000b4dfdf214e77e.tar.gz chat-c39e95c7cb1ad6e812aa3ce4000b4dfdf214e77e.tar.bz2 chat-c39e95c7cb1ad6e812aa3ce4000b4dfdf214e77e.zip |
inital implementation of using GitLab OAuth2 provider for signup/login
Diffstat (limited to 'store')
-rw-r--r-- | store/sql_user_store.go | 26 | ||||
-rw-r--r-- | store/store.go | 1 |
2 files changed, 27 insertions, 0 deletions
diff --git a/store/sql_user_store.go b/store/sql_user_store.go index d8ab4482e..3c25dbb44 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -31,8 +31,10 @@ func NewSqlUserStore(sqlStore *SqlStore) UserStore { table.ColMap("Roles").SetMaxSize(64) table.ColMap("Props").SetMaxSize(4000) table.ColMap("NotifyProps").SetMaxSize(2000) + table.ColMap("AuthService").SetMaxSize(32) table.SetUniqueTogether("Email", "TeamId") table.SetUniqueTogether("Username", "TeamId") + table.SetUniqueTogether("AuthData", "AuthService", "TeamId") } return us @@ -57,6 +59,8 @@ func (us SqlUserStore) UpgradeSchemaIfNeeded() { panic("Failed to set last name from nickname " + err.Error()) } } + + us.CreateColumnIfNotExists("Users", "AuthService", "LastPictureUpdate", "varchar(32)", "") // for OAuth Client } //func (ss SqlStore) CreateColumnIfNotExists(tableName string, columnName string, afterName string, colType string, defaultValue string) bool { @@ -369,6 +373,28 @@ func (us SqlUserStore) GetByEmail(teamId string, email string) StoreChannel { return storeChannel } +func (us SqlUserStore) GetByAuth(teamId string, authData string, authService string) StoreChannel { + + storeChannel := make(StoreChannel) + + go func() { + result := StoreResult{} + + user := model.User{} + + if err := us.GetReplica().SelectOne(&user, "SELECT * FROM Users WHERE TeamId=? AND AuthData=? AND AuthService=?", teamId, authData, authService); err != nil { + result.Err = model.NewAppError("SqlUserStore.GetByAuth", "We couldn't find the existing account", "teamId="+teamId+", authData="+authData+", authService="+authService+", "+err.Error()) + } + + result.Data = &user + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} + func (us SqlUserStore) GetByUsername(teamId string, username string) StoreChannel { storeChannel := make(StoreChannel) diff --git a/store/store.go b/store/store.go index 5b0e13fce..fac3a5bdb 100644 --- a/store/store.go +++ b/store/store.go @@ -85,6 +85,7 @@ type UserStore interface { Get(id string) StoreChannel GetProfiles(teamId string) StoreChannel GetByEmail(teamId string, email string) StoreChannel + GetByAuth(teamId string, authData string, authService string) StoreChannel GetByUsername(teamId string, username string) StoreChannel VerifyEmail(userId string) StoreChannel GetEtagForProfiles(teamId string) StoreChannel |