mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 08:43:25 +08:00
FIX: Allow users to add emails which were deleted before
This commit is contained in:
parent
dd85d44dda
commit
b7e70850e4
|
@ -6,8 +6,10 @@ class EmailLog < ActiveRecord::Base
|
|||
admin_login
|
||||
confirm_new_email
|
||||
confirm_old_email
|
||||
confirm_old_email_add
|
||||
forgot_password
|
||||
notify_old_email
|
||||
notify_old_email_add
|
||||
signup
|
||||
signup_after_approval
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ class EmailUpdater
|
|||
change_req.new_email = email
|
||||
end
|
||||
|
||||
if change_req.change_state.blank?
|
||||
if change_req.change_state.blank? || change_req.change_state == EmailChangeRequest.states[:complete]
|
||||
change_req.change_state = if @user.staff?
|
||||
# Staff users must confirm their old email address first.
|
||||
EmailChangeRequest.states[:authorizing_old]
|
||||
|
|
|
@ -168,6 +168,25 @@ describe EmailUpdater do
|
|||
expect(@change_req.change_state).to eq(EmailChangeRequest.states[:complete])
|
||||
end
|
||||
end
|
||||
|
||||
context 'that was deleted before' do
|
||||
it 'works' do
|
||||
Jobs.expects(:enqueue).once.with(:critical_user_email, has_entries(type: :notify_old_email_add, to_address: old_email))
|
||||
updater.confirm(@change_req.new_email_token.token)
|
||||
expect(user.reload.user_emails.pluck(:email)).to contain_exactly(old_email, new_email)
|
||||
|
||||
user.user_emails.where(email: new_email).delete_all
|
||||
expect(user.reload.user_emails.pluck(:email)).to contain_exactly(old_email)
|
||||
|
||||
Jobs.expects(:enqueue).once.with(:critical_user_email, has_entries(type: :confirm_new_email, to_address: new_email))
|
||||
updater.change_to(new_email, add: true)
|
||||
@change_req = user.email_change_requests.first
|
||||
|
||||
Jobs.expects(:enqueue).once.with(:critical_user_email, has_entries(type: :notify_old_email_add, to_address: old_email))
|
||||
updater.confirm(@change_req.new_email_token.token)
|
||||
expect(user.reload.user_emails.pluck(:email)).to contain_exactly(old_email, new_email)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user