Class: Incline::AccountActivationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/incline/account_activations_controller.rb

Instance Method Summary collapse

Instance Method Details

#editObject

GET /incline/activate/[email protected]



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/incline/account_activations_controller.rb', line 8

def edit
  if logged_in?
    flash[:danger] = 'You cannot reactivate your account.'
    redirect_to main_app.root_url
  else
    user = User.find_by(email: params[:email].downcase)
    if user && !user.activated? && user.authenticated?(:activation, params[:id])
      user.activate
       user
      flash[:success] = 'Your account has been activated.'
      redirect_to user
    else
      flash[:danger] = 'Invalid activation link'
      redirect_to main_app.root_url
    end
  end
end