Sha256: a27b6a20b8710282d9ce24717897cdb08d48bead50a47e6c043a9c65e6d72778

Contents?: true

Size: 859 Bytes

Versions: 9

Compression:

Stored size: 859 Bytes

Contents

class Clearance::SessionsController < ApplicationController
  unloadable

  skip_before_filter :authorize, :only => [:new, :create, :destroy]
  protect_from_forgery :except => :create

  def new
    render :template => 'sessions/new'
  end

  def create
    @user = authenticate(params)
    if @user.nil?
      flash_failure_after_create
      render :template => 'sessions/new', :status => :unauthorized
    else
      sign_in(@user)
      redirect_back_or(url_after_create)
    end
  end

  def destroy
    sign_out
    redirect_to(url_after_destroy)
  end

  private

  def flash_failure_after_create
    flash.now[:notice] = translate(:bad_email_or_password,
      :scope   => [:clearance, :controllers, :sessions],
      :default => "Bad email or password.")
  end

  def url_after_create
    '/'
  end

  def url_after_destroy
    sign_in_url
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
clearance-0.16.3 app/controllers/clearance/sessions_controller.rb
clearance-0.16.2 app/controllers/clearance/sessions_controller.rb
clearance-0.16.1 app/controllers/clearance/sessions_controller.rb
clearance-0.16.0 app/controllers/clearance/sessions_controller.rb
clearance-0.15.0 app/controllers/clearance/sessions_controller.rb
clearance-0.14.0 app/controllers/clearance/sessions_controller.rb
clearance-0.13.2 app/controllers/clearance/sessions_controller.rb
clearance-0.13.0 app/controllers/clearance/sessions_controller.rb
clearance-0.12.0 app/controllers/clearance/sessions_controller.rb