Update error message when trying to switch account with a duplicate email (#3332)

This commit is contained in:
Joram Wilander
2016-06-15 08:02:07 -04:00
committed by GitHub
parent 0f7a8f0fb5
commit f6fc4bdbdb
2 changed files with 9 additions and 1 deletions

View File

@@ -3815,6 +3815,10 @@
"id": "store.sql_user.update.username_taken.app_error",
"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"

View File

@@ -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
}