Class: Outpost::SessionsController

Inherits:
BaseController show all
Defined in:
app/controllers/outpost/sessions_controller.rb

Constant Summary

Constants included from Controller::CustomErrors

Controller::CustomErrors::NOT_FOUND_ERROR_CLASSES

Instance Method Summary collapse

Methods included from Controller::Authentication

#current_user, #require_login

Methods included from Controller::Authorization

#authorize, #authorize_resource, #handle_unauthorized

Methods included from Breadcrumbs

#breadcrumb

Instance Method Details

#createObject



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

def create
  if user = Outpost.user_class.authenticate(
    params[@authentication_attribute], params[:password])

    session[:user_id] = user.id
    user.update_column(:last_login, Time.now)

    redirect_to session[:return_to] || outpost.root_path,
      notice: "Logged in."

    session[:return_to] = nil
  else
    flash.now[:alert] = "Invalid login information."
    render :new
  end
end

#destroyObject



29
30
31
32
33
# File 'app/controllers/outpost/sessions_controller.rb', line 29

def destroy
  @current_user = nil
  session[:user_id] = nil
  redirect_to outpost., notice: "Logged Out."
end

#newObject



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

def new
  redirect_to outpost.root_path if current_user
end