mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
Flush password reset token when email changes
This commit is contained in:
parent
4f09d954e5
commit
be2c2598c7
2 changed files with 5 additions and 1 deletions
|
@ -213,6 +213,7 @@ post '/settings/change_email' do
|
||||||
parent_site.email = params[:email]
|
parent_site.email = params[:email]
|
||||||
parent_site.email_confirmation_token = SecureRandom.hex 3
|
parent_site.email_confirmation_token = SecureRandom.hex 3
|
||||||
parent_site.email_confirmed = false
|
parent_site.email_confirmed = false
|
||||||
|
parent_site.password_reset_token = nil
|
||||||
|
|
||||||
if parent_site.valid?
|
if parent_site.valid?
|
||||||
parent_site.save_changes
|
parent_site.save_changes
|
||||||
|
|
|
@ -13,6 +13,8 @@ describe 'site/settings' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should change email' do
|
it 'should change email' do
|
||||||
|
@site.password_reset_token = 'shouldgoaway'
|
||||||
|
@site.save
|
||||||
@new_email = "#{SecureRandom.uuid.gsub('-', '')}@exampleedsdfdsf.com"
|
@new_email = "#{SecureRandom.uuid.gsub('-', '')}@exampleedsdfdsf.com"
|
||||||
fill_in 'email', with: @new_email
|
fill_in 'email', with: @new_email
|
||||||
click_button 'Change Email'
|
click_button 'Change Email'
|
||||||
|
@ -26,6 +28,7 @@ describe 'site/settings' do
|
||||||
|
|
||||||
@site.reload
|
@site.reload
|
||||||
@site.email.must_equal @new_email
|
@site.email.must_equal @new_email
|
||||||
|
@site.password_reset_token.must_equal nil
|
||||||
EmailWorker.jobs.length.must_equal 1
|
EmailWorker.jobs.length.must_equal 1
|
||||||
args = EmailWorker.jobs.first['args'].first
|
args = EmailWorker.jobs.first['args'].first
|
||||||
args['to'].must_equal @new_email
|
args['to'].must_equal @new_email
|
||||||
|
@ -149,4 +152,4 @@ describe 'site/settings' do
|
||||||
@site.valid_password?('derpie2').must_equal false
|
@site.valid_password?('derpie2').must_equal false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue