[MM-57942] Fix a panic on password is too long (#27449)

* return error from bcrypt, handle gracefully; remove dead code

* linting

* linting

* i18n

* fix test

* fill out translations
Этот коммит содержится в:
Christopher Poile
2024-07-03 17:58:26 -04:00
коммит произвёл GitHub
родитель 5d2bf1ea1c
Коммит cc5e87ae24
8 изменённых файлов: 54 добавлений и 30 удалений

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

@@ -1445,7 +1445,11 @@ func (a *App) UpdatePassword(rctx request.CTX, user *model.User, newPassword str
return model.NewAppError("UpdatePassword", "api.user.update_password.failed.app_error", nil, "", http.StatusInternalServerError)
}
hashedPassword := model.HashPassword(newPassword)
hashedPassword, err := model.HashPassword(newPassword)
if err != nil {
// can't be password length (checked in IsPasswordValid)
return model.NewAppError("UpdatePassword", "api.user.update_password.password_hash.app_error", nil, "user_id="+user.Id, http.StatusInternalServerError).Wrap(err)
}
if err := a.Srv().Store().User().UpdatePassword(user.Id, hashedPassword); err != nil {
return model.NewAppError("UpdatePassword", "api.user.update_password.failed.app_error", nil, "", http.StatusInternalServerError).Wrap(err)