Class: Devise::SessionsController

Inherits:
DeviseController show all
Defined in:
app/controllers/devise/sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#auth_optionsObject (protected)


47
48
49
# File 'app/controllers/devise/sessions_controller.rb', line 47

def auth_options
  { scope: resource_name, recall: "#{controller_path}#new" }
end

#create {|resource| ... } ⇒ Object

POST /resource/sign_in

Yields:


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

def create
  self.resource = warden.authenticate!(auth_options)
  set_flash_message!(:notice, :signed_in)
  (resource_name, resource)
  yield resource if block_given?
  respond_with resource, location: (resource)
end

#destroyObject

DELETE /resource/sign_out


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

def destroy
  signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
  set_flash_message! :notice, :signed_out if signed_out
  yield if block_given?
  respond_to_on_destroy
end

#new {|resource| ... } ⇒ Object

GET /resource/sign_in

Yields:


10
11
12
13
14
15
# File 'app/controllers/devise/sessions_controller.rb', line 10

def new
  self.resource = resource_class.new()
  clean_up_passwords(resource)
  yield resource if block_given?
  respond_with(resource, serialize_options(resource))
end

#serialize_options(resource) ⇒ Object (protected)


40
41
42
43
44
45
# File 'app/controllers/devise/sessions_controller.rb', line 40

def serialize_options(resource)
  methods = resource_class.authentication_keys.dup
  methods = methods.keys if methods.is_a?(Hash)
  methods << :password if resource.respond_to?(:password)
  { methods: methods, only: [:password] }
end

#sign_in_paramsObject (protected)


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

def 
  devise_parameter_sanitizer.sanitize(:sign_in)
end

#translation_scopeObject (protected)


51
52
53
# File 'app/controllers/devise/sessions_controller.rb', line 51

def translation_scope
  'devise.sessions'
end