Class: SessionsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Devise::Controllers::Helpers
Defined in:
app/controllers/sessions_controller.rb

Instance Method Summary collapse

Methods included from Devise::Controllers::Helpers

#devise_controller?, #devise_mapping, included, #resource, #resource_class, #resource_name

Instance Method Details

#createObject

POST /resource/sign_in



15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/sessions_controller.rb', line 15

def create
  if authenticate(resource_name)
    set_flash_message :success, :signed_in
    redirect_back_or_to home_or_root_path
  else
    set_now_flash_message :failure, :invalid
    build_resource
    render :new
  end
end

#destroyObject

GET /resource/sign_out



27
28
29
30
31
# File 'app/controllers/sessions_controller.rb', line 27

def destroy
  set_flash_message :success, :signed_out if signed_in?(resource_name)
  sign_out(resource_name)
  redirect_to root_path
end

#newObject

GET /resource/sign_in



7
8
9
10
11
12
# File 'app/controllers/sessions_controller.rb', line 7

def new
  Devise::FLASH_MESSAGES.each do |message, type|
    set_now_flash_message type, message if params.key?(message)
  end
  build_resource
end