Flush password reset token when email changes

This commit is contained in:
Kyle Drake 2017-01-25 20:45:00 -08:00
parent 4f09d954e5
commit be2c2598c7
2 changed files with 5 additions and 1 deletions

View file

@ -213,6 +213,7 @@ post '/settings/change_email' do
parent_site.email = params[:email]
parent_site.email_confirmation_token = SecureRandom.hex 3
parent_site.email_confirmed = false
parent_site.password_reset_token = nil
if parent_site.valid?
parent_site.save_changes

View file

@ -13,6 +13,8 @@ describe 'site/settings' do
end
it 'should change email' do
@site.password_reset_token = 'shouldgoaway'
@site.save
@new_email = "#{SecureRandom.uuid.gsub('-', '')}@exampleedsdfdsf.com"
fill_in 'email', with: @new_email
click_button 'Change Email'
@ -26,6 +28,7 @@ describe 'site/settings' do
@site.reload
@site.email.must_equal @new_email
@site.password_reset_token.must_equal nil
EmailWorker.jobs.length.must_equal 1
args = EmailWorker.jobs.first['args'].first
args['to'].must_equal @new_email
@ -149,4 +152,4 @@ describe 'site/settings' do
@site.valid_password?('derpie2').must_equal false
end
end
end
end