summaryrefslogtreecommitdiffstats
path: root/store/sql_user_store.go
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-07-23 09:22:17 -0800
committer=Corey Hulen <corey@hulen.com>2015-07-23 09:22:17 -0800
commit8d9449c068902f51a97e7a6605cd226bf4a26f2e (patch)
treeeade41f7f9138de4f156016af9476486c227abec /store/sql_user_store.go
parentc277a98b5d88c81df39f8e33ef1286f72ac04014 (diff)
parenta9d48ff994cd2d03f8e1b2438e50fc6dd0d9bdc2 (diff)
downloadchat-8d9449c068902f51a97e7a6605cd226bf4a26f2e.tar.gz
chat-8d9449c068902f51a97e7a6605cd226bf4a26f2e.tar.bz2
chat-8d9449c068902f51a97e7a6605cd226bf4a26f2e.zip
Merge branch 'master' into mm-1420
Diffstat (limited to 'store/sql_user_store.go')
-rw-r--r--store/sql_user_store.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/store/sql_user_store.go b/store/sql_user_store.go
index 5feef5e69..41aca80c5 100644
--- a/store/sql_user_store.go
+++ b/store/sql_user_store.go
@@ -23,6 +23,7 @@ func NewSqlUserStore(sqlStore *SqlStore) UserStore {
table.ColMap("Username").SetMaxSize(64)
table.ColMap("Password").SetMaxSize(128)
table.ColMap("AuthData").SetMaxSize(128)
+ table.ColMap("AuthService").SetMaxSize(32)
table.ColMap("Email").SetMaxSize(128)
table.ColMap("Nickname").SetMaxSize(64)
table.ColMap("FirstName").SetMaxSize(64)
@@ -56,6 +57,8 @@ func (us SqlUserStore) UpgradeSchemaIfNeeded() {
panic("Failed to set last name from nickname " + err.Error())
}
}
+
+ us.CreateColumnIfNotExists("Users", "AuthService", "AuthData", "varchar(32)", "") // for OAuth Client
}
//func (ss SqlStore) CreateColumnIfNotExists(tableName string, columnName string, afterName string, colType string, defaultValue string) bool {
@@ -371,6 +374,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)