mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Extract auth_options into its own method.
This commit is contained in:
parent
03851cab90
commit
83c47552e8
1 changed files with 7 additions and 3 deletions
|
@ -6,12 +6,12 @@ class Devise::SessionsController < DeviseController
|
||||||
def new
|
def new
|
||||||
resource = build_resource
|
resource = build_resource
|
||||||
clean_up_passwords(resource)
|
clean_up_passwords(resource)
|
||||||
respond_with(resource, stub_options(resource))
|
respond_with(resource, serialize_options(resource))
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST /resource/sign_in
|
# POST /resource/sign_in
|
||||||
def create
|
def create
|
||||||
resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
|
resource = warden.authenticate!(auth_options)
|
||||||
set_flash_message(:notice, :signed_in) if is_navigational_format?
|
set_flash_message(:notice, :signed_in) if is_navigational_format?
|
||||||
sign_in(resource_name, resource)
|
sign_in(resource_name, resource)
|
||||||
respond_with resource, :location => after_sign_in_path_for(resource)
|
respond_with resource, :location => after_sign_in_path_for(resource)
|
||||||
|
@ -38,11 +38,15 @@ class Devise::SessionsController < DeviseController
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def stub_options(resource)
|
def serialize_options(resource)
|
||||||
methods = resource_class.authentication_keys.dup
|
methods = resource_class.authentication_keys.dup
|
||||||
methods = methods.keys if methods.is_a?(Hash)
|
methods = methods.keys if methods.is_a?(Hash)
|
||||||
methods << :password if resource.respond_to?(:password)
|
methods << :password if resource.respond_to?(:password)
|
||||||
{ :methods => methods, :only => [:password] }
|
{ :methods => methods, :only => [:password] }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def auth_options
|
||||||
|
{ :scope => resource_name, :recall => "#{controller_path}#new" }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue