mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Merge pull request #2059 from mattermost/plt-1732
PLT-1732 Update user email when switching to SSO
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -402,7 +402,7 @@ func TestUserStoreUpdateAuthData(t *testing.T) {
|
||||
service := "someservice"
|
||||
authData := "1"
|
||||
|
||||
if err := (<-store.User().UpdateAuthData(u1.Id, service, authData)).Err; err != nil {
|
||||
if err := (<-store.User().UpdateAuthData(u1.Id, service, authData, "")).Err; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ type UserStore interface {
|
||||
UpdateLastActivityAt(userId string, time int64) StoreChannel
|
||||
UpdateUserAndSessionActivity(userId string, sessionId string, time int64) StoreChannel
|
||||
UpdatePassword(userId, newPassword string) StoreChannel
|
||||
UpdateAuthData(userId, service, authData string) StoreChannel
|
||||
UpdateAuthData(userId, service, authData, email string) StoreChannel
|
||||
Get(id string) StoreChannel
|
||||
GetProfiles(teamId string) StoreChannel
|
||||
GetByEmail(teamId string, email string) StoreChannel
|
||||
|
||||
Reference in New Issue
Block a user