Sha256: 7c86c1bdeef22e8bfdd6a8b2d492ecb06211c6d373d4eb98c966d05f3d79feac

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

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)
        if !params[:frontend].blank?
          redirect_to(params[:frontend])
        else
          redirect_back_or_default :controller => :kryptonite, :action => :index
        end
      else
        render :action => :new
      end
    end
  
    def destroy
      current_user_session.destroy
      flash[:notice] = t(:logout_successful)
      if !params[:frontend].blank?
        redirect_to(params[:frontend])
      else
        redirect_back_or_default new_kryptonite_user_session_url
      end
    end

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

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kryptonite-0.1.0 app/controllers/kryptonite/user_sessions_controller.rb
kryptonite-0.0.10 app/controllers/kryptonite/user_sessions_controller.rb
kryptonite-0.0.9 app/controllers/kryptonite/user_sessions_controller.rb
kryptonite-0.0.8 app/controllers/kryptonite/user_sessions_controller.rb
kryptonite-0.0.7 app/controllers/kryptonite/user_sessions_controller.rb
kryptonite-0.0.6 app/controllers/kryptonite/user_sessions_controller.rb