0
0
Fork 0

Add confirmation step for email changes (#6071)

* Add confirmation step for email changes

This adds a confirmation step for email changes of existing users.
Like the initial account confirmation, a confirmation link is sent
to the new address.

Additionally, a notification is sent to the existing address when
the change is initiated. This message includes instruction to reset
the password immediately or to contact the instance admin if the
change was not initiated by the account owner.

Fixes #3871

* Add review fixes
This commit is contained in:
Patrick Figel 2018-01-02 16:55:00 +01:00 committed by Eugen Rochko
parent b6af88192f
commit 04ecf44c2f
12 changed files with 116 additions and 8 deletions

View file

@ -33,6 +33,20 @@ describe UserMailer, type: :mailer do
instance: Rails.configuration.x.local_domain
end
describe 'reconfirmation_instructions' do
let(:mail) { UserMailer.confirmation_instructions(receiver, 'spec') }
it 'renders reconfirmation instructions' do
receiver.update!(email: 'new-email@example.com', locale: nil)
expect(mail.body.encoded).to include 'new-email@example.com'
expect(mail.body.encoded).to include 'spec'
expect(mail.body.encoded).to include Rails.configuration.x.local_domain
expect(mail.subject).to eq I18n.t('devise.mailer.reconfirmation_instructions.subject',
instance: Rails.configuration.x.local_domain,
locale: I18n.default_locale)
end
end
describe 'reset_password_instructions' do
let(:mail) { UserMailer.reset_password_instructions(receiver, 'spec') }
@ -57,4 +71,16 @@ describe UserMailer, type: :mailer do
include_examples 'localized subject',
'devise.mailer.password_change.subject'
end
describe 'email_changed' do
let(:mail) { UserMailer.email_changed(receiver) }
it 'renders email change notification' do
receiver.update!(locale: nil)
expect(mail.body.encoded).to include receiver.email
end
include_examples 'localized subject',
'devise.mailer.email_changed.subject'
end
end