Sha256: bfc9c11ede4ecbeabf712d5e890972c6ff7323c704ed24274e5555c5b612ec94

Contents?: true

Size: 914 Bytes

Versions: 10

Compression:

Stored size: 914 Bytes

Contents

class Clearance::SessionsController < Clearance::BaseController
  before_action :redirect_signed_in_users, only: [:new]
  skip_before_action :require_login, only: [:create, :new, :destroy], raise: false

  def create
    @user = authenticate(params)

    sign_in(@user) do |status|
      if status.success?
        redirect_back_or url_after_create
      else
        flash.now.alert = status.failure_message
        render template: "sessions/new", status: :unauthorized
      end
    end
  end

  def destroy
    sign_out
    redirect_to url_after_destroy
  end

  def new
    render template: "sessions/new"
  end

  private

  def redirect_signed_in_users
    if signed_in?
      redirect_to url_for_signed_in_users
    end
  end

  def url_after_create
    Clearance.configuration.redirect_url
  end

  def url_after_destroy
    sign_in_url
  end

  def url_for_signed_in_users
    url_after_create
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
clearance-2.5.0 app/controllers/clearance/sessions_controller.rb
clearance-2.4.0 app/controllers/clearance/sessions_controller.rb
clearance-2.3.1 app/controllers/clearance/sessions_controller.rb
clearance-2.3.0 app/controllers/clearance/sessions_controller.rb
clearance-2.2.1 app/controllers/clearance/sessions_controller.rb
clearance-2.2.0 app/controllers/clearance/sessions_controller.rb
clearance-2.1.0 app/controllers/clearance/sessions_controller.rb
clearance-2.0.0 app/controllers/clearance/sessions_controller.rb
clearance-2.0.0.beta2 app/controllers/clearance/sessions_controller.rb
clearance-2.0.0.beta1 app/controllers/clearance/sessions_controller.rb