Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Extract auth_options into its own method.
  • Loading branch information
josevalim committed Feb 1, 2012
1 parent 03851ca commit 83c4755
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/controllers/devise/sessions_controller.rb
Expand Up @@ -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)
Expand All @@ -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

0 comments on commit 83c4755

Please sign in to comment.