MM-30041: Return correct error message for user save (#16117)
* MM-30041: Return correct error message for user save We were collapsing all types of user conflict into a single error message. Fixed it by inspecting the field of the invalidError type and returning the correct message. https://mattermost.atlassian.net/browse/MM-30041 ```release-note NONE ``` * Fix test errors * Fix wrong message in test when comparing error messages Co-authored-by: Rodrigo Villablanca <villa061004@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1aadd36644
Коммит
325bff1176
@@ -306,7 +306,14 @@ func (a *App) createUser(user *model.User) (*model.User, *model.AppError) {
|
||||
case errors.As(nErr, &appErr):
|
||||
return nil, appErr
|
||||
case errors.As(nErr, &invErr):
|
||||
return nil, model.NewAppError("createUser", "app.user.save.existing.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
switch invErr.Field {
|
||||
case "email":
|
||||
return nil, model.NewAppError("createUser", "app.user.save.email_exists.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
case "username":
|
||||
return nil, model.NewAppError("createUser", "app.user.save.username_exists.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
default:
|
||||
return nil, model.NewAppError("createUser", "app.user.save.existing.app_error", nil, invErr.Error(), http.StatusBadRequest)
|
||||
}
|
||||
default:
|
||||
return nil, model.NewAppError("createUser", "app.user.save.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user