Sha256: adc20a9fe4a741ef6978c1e364ba78799108825330afecb23018a4d6d5100f50

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

class QuoVadis::SessionsController < ApplicationController
  layout :quo_vadis_layout

  # sign in
  def new
    render 'sessions/new'
  end

  # sign in
  def create
    if user = User.authenticate(params[:username], params[:password])
      self.current_user = user
      QuoVadis.signed_in_hook user, self
      flash[:notice] = t('quo_vadis.flash.after_sign_in') unless t('quo_vadis.flash.after_sign_in').blank?
      redirect_to QuoVadis.signed_in_url(user, original_url)
    else
      QuoVadis.failed_sign_in_hook self
      flash.now[:alert] = t('quo_vadis.flash.failed_sign_in') unless t('quo_vadis.flash.failed_sign_in').blank?
      render 'sessions/new'
    end
  end

  # sign out
  def destroy
    QuoVadis.signed_out_hook current_user, self
    self.current_user = nil
    flash[:notice] = t('quo_vadis.flash.sign_out') unless t('quo_vadis.flash.sign_out').blank?
    redirect_to QuoVadis.signed_out_url
  end

  private

  def original_url
    url = session[:quo_vadis_original_url]
    session[:quo_vadis_original_url] = nil
    url
  end

  def quo_vadis_layout
    QuoVadis.layout
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quo_vadis-1.0.1 app/controllers/quo_vadis/sessions_controller.rb