Class: SessionsController

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

Instance Method Summary collapse

Methods included from Devise::Controllers::InternalHelpers

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

Instance Method Details

#createObject

POST /resource/sign_in



19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/sessions_controller.rb', line 19

def create
  if resource = authenticate(resource_name)
    set_flash_message :notice, :signed_in
    (resource_name, resource, true)
  else
    set_now_flash_message :alert, (warden.message || :invalid)
    clean_up_passwords(build_resource)
    render_with_scope :new
  end
end

#destroyObject

GET /resource/sign_out



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

def destroy
  set_flash_message :notice, :signed_out if signed_in?(resource_name)
  sign_out_and_redirect(resource_name)
end

#newObject

GET /resource/sign_in



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

def new
  unless resource_just_signed_up?
    Devise::FLASH_MESSAGES.each do |message|
      set_now_flash_message :alert, message if params.try(:[], message) == "true"
    end
  end

  build_resource
  render_with_scope :new
end