Skip to content

Commit

Permalink
Generate email change token before changing the address
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Feb 27, 2024
1 parent 47ef813 commit c3a14b1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/controllers/concerns/user_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ def update_user(user, params)
if user.new_email.blank? || user.new_email == user.email
flash[:notice] = t "accounts.update.success"
else
token = user.generate_token_for(:new_email)

user.email = user.new_email

if user.valid?
flash[:notice] = t "accounts.update.success_confirm_needed"

begin
UserMailer.email_confirm(user, user.generate_token_for(:new_email)).deliver_later
UserMailer.email_confirm(user, token).deliver_later
rescue StandardError
# Ignore errors sending email
end
Expand Down

0 comments on commit c3a14b1

Please sign in to comment.