docbrown/app/controllers/email_authorizations_controller.rb
Michael Kohl a4dadfb728
Standardize ActiveRecord order clauses (#9395)
* Change simple order clauses

* Change nested order clauses
2020-07-20 10:00:51 -04:00

15 lines
589 B
Ruby

class EmailAuthorizationsController < ApplicationController
before_action :authenticate_user!
def verify
user = User.find_by(username: params[:username])
raise ActionController::RoutingError, "Not Found" unless current_user == user
email_authorization = user.email_authorizations.order(created_at: :desc).first
correct_token = email_authorization.confirmation_token == params[:confirmation_token]
raise ActionController::RoutingError, "Not Found" unless correct_token
email_authorization.update(verified_at: Time.current)
redirect_to root_path
end
end