diff options
author | =Corey Hulen <corey@hulen.com> | 2016-02-04 10:55:44 -0800 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2016-02-04 10:55:44 -0800 |
commit | cfd4e4de963703191e750ba0abb901c5f6c0c3e4 (patch) | |
tree | d01a656eeeaba9603568a54a164f378608c4a939 /store/sql_user_store.go | |
parent | f1bf70624288bd192b9523764f239eee2a022304 (diff) | |
parent | 44c19ee443831e0e94b5738ecb21a64ce7643247 (diff) | |
download | chat-cfd4e4de963703191e750ba0abb901c5f6c0c3e4.tar.gz chat-cfd4e4de963703191e750ba0abb901c5f6c0c3e4.tar.bz2 chat-cfd4e4de963703191e750ba0abb901c5f6c0c3e4.zip |
Merge branch 'master' into PLT-1851
Diffstat (limited to 'store/sql_user_store.go')
-rw-r--r-- | store/sql_user_store.go | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/store/sql_user_store.go b/store/sql_user_store.go index 0b6970c96..b1544289d 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -305,7 +305,7 @@ func (us SqlUserStore) UpdateFailedPasswordAttempts(userId string, attempts int) return storeChannel } -func (us SqlUserStore) UpdateAuthData(userId, service, authData string) StoreChannel { +func (us SqlUserStore) UpdateAuthData(userId, service, authData, email string) StoreChannel { storeChannel := make(StoreChannel) @@ -314,7 +314,24 @@ func (us SqlUserStore) UpdateAuthData(userId, service, authData string) StoreCha updateAt := model.GetMillis() - if _, err := us.GetMaster().Exec("UPDATE Users SET Password = '', LastPasswordUpdate = :LastPasswordUpdate, UpdateAt = :UpdateAt, FailedAttempts = 0, AuthService = :AuthService, AuthData = :AuthData WHERE Id = :UserId", map[string]interface{}{"LastPasswordUpdate": updateAt, "UpdateAt": updateAt, "UserId": userId, "AuthService": service, "AuthData": authData}); err != nil { + query := ` + UPDATE + Users + SET + Password = '', + LastPasswordUpdate = :LastPasswordUpdate, + UpdateAt = :UpdateAt, + FailedAttempts = 0, + AuthService = :AuthService, + AuthData = :AuthData` + + if len(email) != 0 { + query += ", Email = :Email" + } + + query += " WHERE Id = :UserId" + + if _, err := us.GetMaster().Exec(query, map[string]interface{}{"LastPasswordUpdate": updateAt, "UpdateAt": updateAt, "UserId": userId, "AuthService": service, "AuthData": authData, "Email": email}); err != nil { result.Err = model.NewLocAppError("SqlUserStore.UpdateAuthData", "store.sql_user.update_auth_data.app_error", nil, "id="+userId+", "+err.Error()) } else { result.Data = userId |