mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: When admin changes another user's email auto-confirm the change (#9001)
When admin changes a user's email from the preferences page of that user: * The user will not be sent an email to confirm that their email is changing. They will be sent a reset password email so they can set the password for their account at the new email address. * The user will still be sent an email to their old email to inform them that it was changed. * Admin and staff users still need to follow the same old + new confirm process, as do users changing their own email.
This commit is contained in:
@@ -655,7 +655,7 @@ RSpec.describe Users::OmniauthCallbacksController do
|
||||
username: 'boguslaw',
|
||||
email: new_email }
|
||||
|
||||
updater = EmailUpdater.new(user.guardian, user)
|
||||
updater = EmailUpdater.new(guardian: user.guardian, user: user)
|
||||
updater.change_to(new_email)
|
||||
|
||||
user.reload
|
||||
|
||||
@@ -26,7 +26,7 @@ describe UsersEmailController do
|
||||
end
|
||||
|
||||
it 'does not change email if accounts mismatch' do
|
||||
updater = EmailUpdater.new(user.guardian, user)
|
||||
updater = EmailUpdater.new(guardian: user.guardian, user: user)
|
||||
updater.change_to('new.n.cool@example.com')
|
||||
|
||||
old_email = user.email
|
||||
@@ -42,7 +42,7 @@ describe UsersEmailController do
|
||||
end
|
||||
|
||||
context "with a valid user" do
|
||||
let(:updater) { EmailUpdater.new(user.guardian, user) }
|
||||
let(:updater) { EmailUpdater.new(guardian: user.guardian, user: user) }
|
||||
|
||||
before do
|
||||
sign_in(user)
|
||||
@@ -221,7 +221,7 @@ describe UsersEmailController do
|
||||
it 'bans change when accounts do not match' do
|
||||
|
||||
sign_in(user)
|
||||
updater = EmailUpdater.new(moderator.guardian, moderator)
|
||||
updater = EmailUpdater.new(guardian: moderator.guardian, user: moderator)
|
||||
updater.change_to('new.n.cool@example.com')
|
||||
|
||||
get "/u/confirm-old-email/#{moderator.email_tokens.last.token}"
|
||||
@@ -235,7 +235,7 @@ describe UsersEmailController do
|
||||
it 'confirms with a correct token' do
|
||||
# NOTE: only moderators need to confirm both old and new
|
||||
sign_in(moderator)
|
||||
updater = EmailUpdater.new(moderator.guardian, moderator)
|
||||
updater = EmailUpdater.new(guardian: moderator.guardian, user: moderator)
|
||||
updater.change_to('new.n.cool@example.com')
|
||||
|
||||
get "/u/confirm-old-email/#{moderator.email_tokens.last.token}"
|
||||
|
||||
Reference in New Issue
Block a user