Class: AccountActivationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- BarkestCore::ApplicationControllerBase
- ApplicationController
- AccountActivationsController
- Defined in:
- app/controllers/account_activations_controller.rb
Overview
This is a simple controller that handles account activation requests.
Instance Method Summary collapse
-
#edit ⇒ Object
Takes in the user’s email address and activation token as parameters.
Methods inherited from BarkestCore::ApplicationControllerBase
#authorize!, #show_denial_reason?
Methods included from BarkestCore::StatusHelper
#clear_system_status, #show_system_status, #status_button_label, #status_redirect_url
Methods included from BarkestCore::RecaptchaHelper
#add_recaptcha_challenge, #verify_recaptcha_challenge
Methods included from BarkestCore::SessionsHelper
#current_user, #current_user?, #forget, #log_in, #log_out, #logged_in?, #redirect_back_or, #remember, #store_location, #store_location_and_redirect_to, #system_admin?
Instance Method Details
#edit ⇒ Object
Takes in the user’s email address and activation token as parameters.
If the activation token is correct for the email, then the account is activated. If a user is logged in, then the user must be activated already, so alert them that reactivation is not allowed.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/account_activations_controller.rb', line 11 def edit if logged_in? flash[:danger] = 'You cannot reactivate your account.' redirect_to root_url else user = User.find_by(email: params[:email].downcase) if user && !user.activated? && user.authenticated?(:activation, params[:id]) user.activate log_in user flash[:success] = 'Your account has been activated.' redirect_to user else flash[:danger] = 'Invalid activation link' redirect_to root_url end end end |