Sha256: bc8b18f3a7ac8351762e018024f086c3c050ef5949f5baade915dc264f6d64de

Contents?: true

Size: 924 Bytes

Versions: 4

Compression:

Stored size: 924 Bytes

Contents

class Clearance::SessionsController < ApplicationController
  skip_before_filter :authorize, :only => [:create, :new, :destroy]
  protect_from_forgery :except => :create

  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

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

  private

  def flash_failure_after_create
    flash.now[:notice] = translate(:bad_email_or_password,
      :scope => [:clearance, :controllers, :sessions],
      :default => t('flashes.failure_after_create', :sign_up_path => sign_up_path).html_safe)
  end

  def url_after_create
    Clearance.configuration.redirect_url
  end

  def url_after_destroy
    sign_in_url
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
clearance-1.0.1 app/controllers/clearance/sessions_controller.rb
clearance-1.0.0 app/controllers/clearance/sessions_controller.rb
clearance-1.0.0.rc8 app/controllers/clearance/sessions_controller.rb
clearance-1.0.0.rc7 app/controllers/clearance/sessions_controller.rb