Sha256: 48d4ed84a52b0a8ae3bc51997a2ecc27bb43842542c93f19712ca4c1d0305ecf

Contents?: true

Size: 933 Bytes

Versions: 5

Compression:

Stored size: 933 Bytes

Contents

class Authenticate::SessionsController < Authenticate::AuthenticateController
  before_action :redirect_signed_in_users, only: [:new]
  skip_before_action :require_authentication, only: [:create, :new, :destroy], raise: false


  def new
    render template: 'sessions/new'
  end

  def create
    @user = authenticate(params)
    login(@user) do |status|
      if status.success?
        redirect_back_or url_after_create
      else
        flash.now.notice = status.message
        render template: 'sessions/new', status: :unauthorized
      end
    end
  end

  def destroy
    logout
    redirect_to url_after_destroy
  end

  private

  def redirect_signed_in_users
    if authenticated?
      redirect_to url_for_signed_in_users
    end
  end

  def url_after_create
    Authenticate.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

5 entries across 5 versions & 1 rubygems

Version Path
authenticate-0.3.1 app/controllers/authenticate/sessions_controller.rb
authenticate-0.3.0 app/controllers/authenticate/sessions_controller.rb
authenticate-0.2.3 app/controllers/authenticate/sessions_controller.rb
authenticate-0.2.2 app/controllers/authenticate/sessions_controller.rb
authenticate-0.2.1 app/controllers/authenticate/sessions_controller.rb