X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/124909a64c4c2b739cebfff69fcf100e6b6d2457..ad2739347b5fc7c57d8b7131580fda10cc77f108:/app/controllers/confirmations_controller.rb diff --git a/app/controllers/confirmations_controller.rb b/app/controllers/confirmations_controller.rb index 65f560571..604e6b5b3 100644 --- a/app/controllers/confirmations_controller.rb +++ b/app/controllers/confirmations_controller.rb @@ -75,9 +75,12 @@ class ConfirmationsController < ApplicationController def confirm_email if request.post? - token = UserToken.find_by(:token => params[:confirm_string]) - if token&.user&.new_email? - self.current_user = token.user + token = params[:confirm_string] + + self.current_user = User.find_by_token_for(:new_email, token) || + UserToken.unexpired.find_by(:token => params[:confirm_string])&.user + + if current_user&.new_email? current_user.email = current_user.new_email current_user.new_email = nil current_user.email_valid = true @@ -94,7 +97,7 @@ class ConfirmationsController < ApplicationController current_user.tokens.delete_all session[:user] = current_user.id session[:fingerprint] = current_user.fingerprint - elsif token + elsif current_user flash[:error] = t ".failure" else flash[:error] = t ".unknown_token"