diff options
-rw-r--r-- | i18n/en.json | 4 | ||||
-rw-r--r-- | store/sql_user_store.go | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/i18n/en.json b/i18n/en.json index 337678d82..62cf3a38b 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -3816,6 +3816,10 @@ "translation": "This username is already taken. Please choose another." }, { + "id": "store.sql_user.update_auth_data.email_exists.app_error", + "translation": "Unable to switch account to {{.Service}}. An account using the email {{.Email}} already exists." + }, + { "id": "store.sql_user.update_auth_data.app_error", "translation": "We couldn't update the auth data" }, diff --git a/store/sql_user_store.go b/store/sql_user_store.go index 6313a91e2..635e53be6 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -348,7 +348,11 @@ func (us SqlUserStore) UpdateAuthData(userId string, service string, authData *s 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()) + if IsUniqueConstraintError(err.Error(), []string{"Email", "users_email_key", "idx_users_email_unique"}) { + result.Err = model.NewLocAppError("SqlUserStore.UpdateAuthData", "store.sql_user.update_auth_data.email_exists.app_error", map[string]interface{}{"Service": service, "Email": email}, "user_id="+userId+", "+err.Error()) + } else { + result.Err = model.NewLocAppError("SqlUserStore.UpdateAuthData", "store.sql_user.update_auth_data.app_error", nil, "id="+userId+", "+err.Error()) + } } else { result.Data = userId } |