Class: Devise::SessionsController

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

Constant Summary

Constants included from Controllers::SharedHelpers

Controllers::SharedHelpers::MIME_REFERENCES

Instance Method Summary collapse

Methods included from Controllers::InternalHelpers

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

Instance Method Details

#createObject

POST /resource/sign_in



14
15
16
17
18
19
# File 'app/controllers/devise/sessions_controller.rb', line 14

def create
  resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
  set_flash_message(:notice, :signed_in) if is_navigational_format?
  (resource_name, resource)
  respond_with resource, :location => (resource)
end

#destroyObject

DELETE /resource/sign_out



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/devise/sessions_controller.rb', line 22

def destroy
  signed_in = signed_in?(resource_name)
  redirect_path = after_sign_out_path_for(resource_name)
  Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
  set_flash_message :notice, :signed_out if signed_in

  # We actually need to hardcode this as Rails default responder doesn't
  # support returning empty response on GET request
  respond_to do |format|
    format.any(*navigational_formats) { redirect_to redirect_path }
    format.all do
      method = "to_#{request_format}"
      text = {}.respond_to?(method) ? {}.send(method) : ""
      render :text => text, :status => :ok
    end
  end
end

#newObject

GET /resource/sign_in



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

def new
  resource = build_resource
  clean_up_passwords(resource)
  respond_with_navigational(resource, stub_options(resource)){ render_with_scope :new }
end