Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 49 lines (41 sloc) 1.704 kb
02e8c04 @josevalim Update views generator and now have scoped views.
josevalim authored
1 class Devise::SessionsController < ApplicationController
a5ba2ac @carlosantoniodasilva Use prepend_before_filter in require_no_authentication.
carlosantoniodasilva authored
2 prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
ab9d856 @josevalim Add a deprecation warning for previous controller authorization style.
josevalim authored
3 prepend_before_filter :allow_params_authentication!, :only => :create
b581f86 @josevalim DRY up controllers.
josevalim authored
4 include Devise::Controllers::InternalHelpers
dede8af @josevalim Do not include Devise internal helpers in application controller.
josevalim authored
5
b21b629 @carlosantoniodasilva Better documentation.
carlosantoniodasilva authored
6 # GET /resource/sign_in
7ce49cb @carlosantoniodasilva Configuring session and password controllers as engine, and getting inte...
carlosantoniodasilva authored
7 def new
4a4dcb3 @josevalim sessions/new also responds to xml and json now
josevalim authored
8 resource = build_resource
9 clean_up_passwords(resource)
10 respond_with_navigational(resource, stub_options(resource)){ render_with_scope :new }
7ce49cb @carlosantoniodasilva Configuring session and password controllers as engine, and getting inte...
carlosantoniodasilva authored
11 end
12
b21b629 @carlosantoniodasilva Better documentation.
carlosantoniodasilva authored
13 # POST /resource/sign_in
7ce49cb @carlosantoniodasilva Configuring session and password controllers as engine, and getting inte...
carlosantoniodasilva authored
14 def create
ef34800 @josevalim Ensure we are pointing to the proper sessions controller on failure.
josevalim authored
15 resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
e8e3df3 @sikachu Add support for non-navigational format response to SessionsController
sikachu authored
16 set_flash_message(:notice, :signed_in) if is_navigational_format?
17 sign_in(resource_name, resource)
18 respond_with resource, :location => redirect_location(resource_name, resource)
7ce49cb @carlosantoniodasilva Configuring session and password controllers as engine, and getting inte...
carlosantoniodasilva authored
19 end
20
b21b629 @carlosantoniodasilva Better documentation.
carlosantoniodasilva authored
21 # GET /resource/sign_out
7ce49cb @carlosantoniodasilva Configuring session and password controllers as engine, and getting inte...
carlosantoniodasilva authored
22 def destroy
e4c5158 @josevalim Sign out by default will destroy the existing session.
josevalim authored
23 signed_in = signed_in?(resource_name)
0487e9e @sikachu Add support for `destory_user_session_path` in another non-navigational ...
sikachu authored
24 Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
e4c5158 @josevalim Sign out by default will destroy the existing session.
josevalim authored
25 set_flash_message :notice, :signed_out if signed_in
0487e9e @sikachu Add support for `destory_user_session_path` in another non-navigational ...
sikachu authored
26
5b94d9b @josevalim Refactor a bit navigational format responses, to not call to_sym and reu...
josevalim authored
27 # We actually need to hardcode this, as Rails default responder doesn't
0487e9e @sikachu Add support for `destory_user_session_path` in another non-navigational ...
sikachu authored
28 # support returning empty response on GET request
29 respond_to do |format|
30 format.any(*navigational_formats) { redirect_to after_sign_out_path_for(resource_name) }
5b94d9b @josevalim Refactor a bit navigational format responses, to not call to_sym and reu...
josevalim authored
31 format.all do
32 method = "to_#{request_format}"
33 text = {}.respond_to?(method) ? {}.send(method) : ""
34 render :text => text, :status => :ok
35 end
0487e9e @sikachu Add support for `destory_user_session_path` in another non-navigational ...
sikachu authored
36 end
7ce49cb @carlosantoniodasilva Configuring session and password controllers as engine, and getting inte...
carlosantoniodasilva authored
37 end
4a4dcb3 @josevalim sessions/new also responds to xml and json now
josevalim authored
38
39 protected
40
41 def stub_options(resource)
3cedba1 @ches Fix optional enforcement of particular authentication keys
ches authored
42 methods = resource_class.authentication_keys.dup
43 methods = methods.keys if methods.is_a?(Hash)
44 methods << :password if resource.respond_to?(:password)
45 { :methods => methods, :only => [:password] }
4a4dcb3 @josevalim sessions/new also responds to xml and json now
josevalim authored
46 end
3cedba1 @ches Fix optional enforcement of particular authentication keys
ches authored
47 end
48
Something went wrong with that request. Please try again.