Class: Clearance::SessionsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/clearance/sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/clearance/sessions_controller.rb', line 5

def create
  @user = authenticate(params)

  (@user) do |status|
    if status.success?
      redirect_back_or url_after_create
    else
      flash.now.alert = status.failure_message
      render template: "sessions/new", status: :unauthorized
    end
  end
end

#destroyObject



18
19
20
21
# File 'app/controllers/clearance/sessions_controller.rb', line 18

def destroy
  sign_out
  redirect_to url_after_destroy, status: :see_other
end

#newObject



23
24
25
# File 'app/controllers/clearance/sessions_controller.rb', line 23

def new
  render template: "sessions/new"
end

#redirect_signed_in_usersObject (private)



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

def redirect_signed_in_users
  if signed_in?
    redirect_to url_for_signed_in_users
  end
end

#url_after_createObject (private)



35
36
37
# File 'app/controllers/clearance/sessions_controller.rb', line 35

def url_after_create
  Clearance.configuration.redirect_url
end

#url_after_destroyObject (private)



39
40
41
# File 'app/controllers/clearance/sessions_controller.rb', line 39

def url_after_destroy
  Clearance.configuration.url_after_destroy || 
end

#url_for_signed_in_usersObject (private)



43
44
45
# File 'app/controllers/clearance/sessions_controller.rb', line 43

def url_for_signed_in_users
  url_after_create
end