mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 10:41:25 +08:00
FIX: Allow staff to reset passwords by username (#15709)
When staff visits the user profile of another user, the `email` field in the model is empty. In this case, staff cannot send the reset email password because nothing is passed in the `login` field. This commit changes the behavior for staff users to allow resetting password by username instead.
This commit is contained in:
@ -434,7 +434,7 @@ class SessionController < ApplicationController
|
||||
RateLimiter.new(nil, "forgot-password-hr-#{request.remote_ip}", 6, 1.hour).performed!
|
||||
RateLimiter.new(nil, "forgot-password-min-#{request.remote_ip}", 3, 1.minute).performed!
|
||||
|
||||
user = if SiteSetting.hide_email_address_taken
|
||||
user = if SiteSetting.hide_email_address_taken && !current_user&.staff?
|
||||
raise Discourse::InvalidParameters.new(:login) if EmailValidator.email_regex !~ normalized_login_param
|
||||
User.real.where(staged: false).find_by_email(Email.downcase(normalized_login_param))
|
||||
else
|
||||
|
Reference in New Issue
Block a user