Sha256: 092ea1a1668947b65d675627365b13175cf3f5c8fae06ddbb18783146ad75062

Contents?: true

Size: 1.63 KB

Versions: 9

Compression:

Stored size: 1.63 KB

Contents

class Devise::SessionsController < DeviseController
  prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
  prepend_before_filter :allow_params_authentication!, :only => :create

  # GET /resource/sign_in
  def new
    resource = build_resource
    clean_up_passwords(resource)
    respond_with(resource, serialize_options(resource))
  end

  # POST /resource/sign_in
  def create
    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)
  end

  # DELETE /resource/sign_out
  def destroy
    redirect_path = after_sign_out_path_for(resource_name)
    signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
    set_flash_message :notice, :signed_out if signed_out

    # We actually need to hardcode this as Rails default responder doesn't
    # support returning empty response on GET request
    respond_to do |format|
      format.any(*navigational_formats) { redirect_to redirect_path }
      format.all do
        method = "to_#{request_format}"
        text = {}.respond_to?(method) ? {}.send(method) : ""
        render :text => text, :status => :ok
      end
    end
  end

  protected

  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

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
devise-2.0.6 app/controllers/devise/sessions_controller.rb
devise-2.0.5 app/controllers/devise/sessions_controller.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/devise-2.0.4/app/controllers/devise/sessions_controller.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/devise-2.0.4/app/controllers/devise/sessions_controller.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/devise-2.0.4/app/controllers/devise/sessions_controller.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/devise-2.0.4/app/controllers/devise/sessions_controller.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/devise-2.0.4/app/controllers/devise/sessions_controller.rb
devise-2.1.0.rc app/controllers/devise/sessions_controller.rb
devise-2.0.4 app/controllers/devise/sessions_controller.rb