Class: Clearance::SessionsController

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

Instance Method Summary collapse

Instance Method Details

#createObject


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

def create
  @user = authenticate(params)

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

#destroyObject


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

def destroy
  sign_out
  redirect_to url_after_destroy
end

#newObject


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

def new
  render template: "sessions/new"
end

#redirect_signed_in_usersObject (private)


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

def redirect_signed_in_users
  if signed_in?
    redirect_to url_for_signed_in_users
  end
end

#url_after_createObject (private)


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

def url_after_create
  Clearance.configuration.redirect_url
end

#url_after_destroyObject (private)


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

def url_after_destroy
  
end

#url_for_signed_in_usersObject (private)


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

def url_for_signed_in_users
  url_after_create
end