diff --git a/app/controllers/devise/sessions_controller.rb b/app/controllers/devise/sessions_controller.rb index a2c7c3b1..69579030 100644 --- a/app/controllers/devise/sessions_controller.rb +++ b/app/controllers/devise/sessions_controller.rb @@ -6,12 +6,12 @@ class Devise::SessionsController < DeviseController def new resource = build_resource clean_up_passwords(resource) - respond_with(resource, stub_options(resource)) + respond_with(resource, serialize_options(resource)) end # POST /resource/sign_in 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? sign_in(resource_name, resource) respond_with resource, :location => after_sign_in_path_for(resource) @@ -38,11 +38,15 @@ class Devise::SessionsController < DeviseController protected - def stub_options(resource) + 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 + + def auth_options + { :scope => resource_name, :recall => "#{controller_path}#new" } + end end