Fix error not appearing when updating to existing username (#6255)

Этот коммит содержится в:
Joram Wilander
2017-04-28 10:11:26 -04:00
коммит произвёл Christopher Speller
родитель 1b82d98cdb
Коммит 514f038f44
3 изменённых файлов: 10 добавлений и 3 удалений

Просмотреть файл

@@ -797,6 +797,13 @@ func TestPatchUser(t *testing.T) {
t.Fatal("NotifyProps did not update properly")
}
patch.Username = new(string)
*patch.Username = th.BasicUser2.Username
_, resp = Client.PatchUser(user.Id, patch)
CheckBadRequestStatus(t, resp)
patch.Username = nil
_, resp = Client.PatchUser("junk", patch)
CheckBadRequestStatus(t, resp)

Просмотреть файл

@@ -183,9 +183,9 @@ func (us SqlUserStore) Update(user *model.User, trustedUpdateData bool) StoreCha
if count, err := us.GetMaster().Update(user); err != nil {
if IsUniqueConstraintError(err.Error(), []string{"Email", "users_email_key", "idx_users_email_unique"}) {
result.Err = model.NewLocAppError("SqlUserStore.Update", "store.sql_user.update.email_taken.app_error", nil, "user_id="+user.Id+", "+err.Error())
result.Err = model.NewAppError("SqlUserStore.Update", "store.sql_user.update.email_taken.app_error", nil, "user_id="+user.Id+", "+err.Error(), http.StatusBadRequest)
} else if IsUniqueConstraintError(err.Error(), []string{"Username", "users_username_key", "idx_users_username_unique"}) {
result.Err = model.NewLocAppError("SqlUserStore.Update", "store.sql_user.update.username_taken.app_error", nil, "user_id="+user.Id+", "+err.Error())
result.Err = model.NewAppError("SqlUserStore.Update", "store.sql_user.update.username_taken.app_error", nil, "user_id="+user.Id+", "+err.Error(), http.StatusBadRequest)
} else {
result.Err = model.NewLocAppError("SqlUserStore.Update", "store.sql_user.update.updating.app_error", nil, "user_id="+user.Id+", "+err.Error())
}

Просмотреть файл

@@ -532,7 +532,7 @@ export function updateUser(user, type, success, error) {
if (data && success) {
success(data);
} else if (data == null && error) {
const serverError = getState().requests.users.updateUser.error;
const serverError = getState().requests.users.updateMe.error;
error({id: serverError.server_error_id, ...serverError});
}
}