Class: ActiveAuthentication::SessionsController

Inherits:
ActiveAuthenticationController show all
Includes:
ActiveSupport::Callbacks
Defined in:
app/controllers/active_authentication/sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/active_authentication/sessions_controller.rb', line 12

def create
  @user = scope.authenticate_by email: params[:email], password: params[:password]

  if @user.present?
    run_callbacks :successful_sign_in do
       @user
    end

    redirect_to root_path, notice: t(".success")
  else
    run_callbacks :failed_sign_in do
      flash[:alert] = t(".invalid_email_or_password")
    end

    render :new, status: :unprocessable_entity
  end
end

#destroyObject



30
31
32
33
34
35
# File 'app/controllers/active_authentication/sessions_controller.rb', line 30

def destroy
  run_callbacks :sign_out do
    sign_out
  end
  redirect_to root_url, notice: t(".success")
end

#newObject



9
10
# File 'app/controllers/active_authentication/sessions_controller.rb', line 9

def new
end