MM-58349 Don't allow remote user to create sessions or reset password (#27215)
Automatic Merge
Этот коммит содержится в:
@@ -1440,6 +1440,11 @@ func (a *App) UpdatePassword(rctx request.CTX, user *model.User, newPassword str
|
||||
return err
|
||||
}
|
||||
|
||||
// remote/synthetic users cannot update password via any mechanism
|
||||
if user.IsRemote() {
|
||||
return model.NewAppError("UpdatePassword", "api.user.update_password.failed.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
hashedPassword := model.HashPassword(newPassword)
|
||||
|
||||
if err := a.Srv().Store().User().UpdatePassword(user.Id, hashedPassword); err != nil {
|
||||
@@ -1475,6 +1480,11 @@ func (a *App) UpdateHashedPasswordByUserId(userID, newHashedPassword string) *mo
|
||||
}
|
||||
|
||||
func (a *App) UpdateHashedPassword(user *model.User, newHashedPassword string) *model.AppError {
|
||||
// remote/synthetic users cannot update password via any mechanism
|
||||
if user.IsRemote() {
|
||||
return model.NewAppError("UpdatePassword", "api.user.update_password.failed.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if err := a.Srv().Store().User().UpdatePassword(user.Id, newHashedPassword); err != nil {
|
||||
return model.NewAppError("UpdatePassword", "api.user.update_password.failed.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
@@ -1520,6 +1530,11 @@ func (a *App) resetPasswordFromToken(c request.CTX, userSuppliedTokenString, new
|
||||
return model.NewAppError("ResetPasswordFromCode", "api.user.reset_password.sso.app_error", nil, "userId="+user.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
// don't allow password reset for remote/synthetic users
|
||||
if user.IsRemote() {
|
||||
return model.NewAppError("resetPassword", "api.user.reset_password.broken_token.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
T := i18n.GetUserTranslations(user.Locale)
|
||||
|
||||
if err := a.UpdatePasswordSendEmail(c, user, newPassword, T("api.user.reset_password.method")); err != nil {
|
||||
@@ -1539,6 +1554,11 @@ func (a *App) SendPasswordReset(rctx request.CTX, email string, siteURL string)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// don't allow password reset for remote/synthetic users
|
||||
if user.IsRemote() {
|
||||
return false, model.NewAppError("SendPasswordReset", "api.user.send_password_reset.send.app_error", nil, "userId="+user.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if user.AuthData != nil && *user.AuthData != "" {
|
||||
return false, model.NewAppError("SendPasswordReset", "api.user.send_password_reset.sso.app_error", nil, "userId="+user.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user