Sha256: e1c3641ac1c443cfd89ca18a829bf36caa2c7730c3dd6a10ea2b998048dafb27

Contents?: true

Size: 880 Bytes

Versions: 1

Compression:

Stored size: 880 Bytes

Contents

class QuoVadis::SessionsController < ApplicationController

  # 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, request
      redirect_to QuoVadis.signed_in_url(user, original_url), :notice => t('quo_vadis.flash.after_sign_in')
    else
      QuoVadis.failed_sign_in_hook request
      flash.now[:alert] = t('quo_vadis.flash.failed_sign_in')
      render 'sessions/new'
    end
  end

  # sign out
  def destroy
    QuoVadis.signed_out_hook current_user, request
    self.current_user = nil
    redirect_to QuoVadis.signed_out_url, :notice => t('quo_vadis.flash.sign_out')
  end

  private

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

end

Version data entries

1 entries across 1 versions & 1 rubygems

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