* Add automated email ownership emails This is task Michael does manually a lot. There are a lot of cases where we need to validate that an individual has access to the email address associated with their DEV account. This automates a singificant portion of that, and hopefully we can use it in a lot of places.
14 lines
555 B
Ruby
14 lines
555 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
|
|
raise ActionController::RoutingError, "Not Found" unless email_authorization.confirmation_token == params[:confirmation_token]
|
|
|
|
email_authorization.update(verified_at: Time.current)
|
|
redirect_to root_path
|
|
end
|
|
end
|