Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 45 lines (39 sloc) 1.553 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 ]
b581f86 @josevalim DRY up controllers.
josevalim authored
3 include Devise::Controllers::InternalHelpers
dede8af @josevalim Do not include Devise internal helpers in application controller.
josevalim authored
4
b21b629 @carlosantoniodasilva Better documentation.
carlosantoniodasilva authored
5 # GET /resource/sign_in
7ce49cb @carlosantoniodasilva Configuring session and password controllers as engine, and getting inte...
carlosantoniodasilva authored
6 def new
4a4dcb3 @josevalim sessions/new also responds to xml and json now
josevalim authored
7 resource = build_resource
8 clean_up_passwords(resource)
9 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
10 end
11
b21b629 @carlosantoniodasilva Better documentation.
carlosantoniodasilva authored
12 # POST /resource/sign_in
7ce49cb @carlosantoniodasilva Configuring session and password controllers as engine, and getting inte...
carlosantoniodasilva authored
13 def create
ef34800 @josevalim Ensure we are pointing to the proper sessions controller on failure.
josevalim authored
14 resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
e8e3df3 @sikachu Add support for non-navigational format response to SessionsController
sikachu authored
15 set_flash_message(:notice, :signed_in) if is_navigational_format?
16 sign_in(resource_name, resource)
17 respond_with resource, :location => redirect_location(resource_name, resource)
7ce49cb @carlosantoniodasilva Configuring session and password controllers as engine, and getting inte...
carlosantoniodasilva authored
18 end
19
b21b629 @carlosantoniodasilva Better documentation.
carlosantoniodasilva authored
20 # GET /resource/sign_out
7ce49cb @carlosantoniodasilva Configuring session and password controllers as engine, and getting inte...
carlosantoniodasilva authored
21 def destroy
e4c5158 @josevalim Sign out by default will destroy the existing session.
josevalim authored
22 signed_in = signed_in?(resource_name)
0487e9e @sikachu Add support for `destory_user_session_path` in another non-navigational ...
sikachu authored
23 Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
e4c5158 @josevalim Sign out by default will destroy the existing session.
josevalim authored
24 set_flash_message :notice, :signed_out if signed_in
0487e9e @sikachu Add support for `destory_user_session_path` in another non-navigational ...
sikachu authored
25
5b94d9b @josevalim Refactor a bit navigational format responses, to not call to_sym and reu...
josevalim authored
26 # 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
27 # support returning empty response on GET request
28 respond_to do |format|
29 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
30 format.all do
31 method = "to_#{request_format}"
32 text = {}.respond_to?(method) ? {}.send(method) : ""
33 render :text => text, :status => :ok
34 end
0487e9e @sikachu Add support for `destory_user_session_path` in another non-navigational ...
sikachu authored
35 end
7ce49cb @carlosantoniodasilva Configuring session and password controllers as engine, and getting inte...
carlosantoniodasilva authored
36 end
4a4dcb3 @josevalim sessions/new also responds to xml and json now
josevalim authored
37
38 protected
39
40 def stub_options(resource)
41 hash = { :only => resource_class.authentication_keys }
42 hash[:methods] = [:password] if resource.respond_to?(:password)
43 hash
44 end
45 end
Something went wrong with that request. Please try again.