From 83c47552e88d2f87250b0f3664ea41aa8e685d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 1 Feb 2012 09:26:33 +0100 Subject: [PATCH] Extract auth_options into its own method. --- app/controllers/devise/sessions_controller.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/devise/sessions_controller.rb b/app/controllers/devise/sessions_controller.rb index a2c7c3b145..69579030ce 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 @@ def destroy 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