Sha256: 7e198a283cbcad29585208305949a2379e917c17e0729923c7449e95d79f92db

Contents?: true

Size: 988 Bytes

Versions: 3

Compression:

Stored size: 988 Bytes

Contents

module Kryptonite
  class UserSessionsController < Kryptonite::KryptoniteController
    
    unloadable
    
    skip_before_filter :authorise, :only => [:new, :create]
    before_filter :requires_no_session_user, :except => [:destroy]
  
    layout 'kryptonite_auth'
  
    def new
      @user_session = Kryptonite::UserSession.new
    end
  
    def create
      @user_session = Kryptonite::UserSession.new params[:kryptonite_user_session]
      if @user_session.save
        flash[:notice] = t(:login_successful)
        redirect_back_or_default :controller => :kryptonite, :action => :index
      else
        render :action => :new
      end
    end
  
    def destroy
      current_user_session.destroy
      flash[:notice] = t(:logout_successful)
      redirect_back_or_default new_kryptonite_user_session_url
    end

  private
  
    def requires_no_session_user
      if current_user
        redirect_to :controller => :kryptonite, :action => :index
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kryptonite-0.0.4 app/controllers/kryptonite/user_sessions_controller.rb
kryptonite-0.0.3 app/controllers/kryptonite/user_sessions_controller.rb
kryptonite-0.0.2 app/controllers/kryptonite/user_sessions_controller.rb