Sha256: b5a53bfe635e123e7f1ba30b5c3c011cefa3cca9f4326ac15bf7d58cd8d8b2e0

Contents?: true

Size: 1.33 KB

Versions: 14

Compression:

Stored size: 1.33 KB

Contents

class Spud::ApplicationController < ActionController::Base
	unloadable
	protect_from_forgery
	helper_method :current_user_session, :current_user
	

  private
    def current_user_session
      return @current_user_session if defined?(@current_user_session)
      @current_user_session = SpudUserSession.find
    end

    def current_user
      return @current_user if defined?(@current_user)
      @current_user = current_user_session && current_user_session.spud_user
    end
    def current_user_permissions
      return @current_user_permissions if defined?(@current_user_permissions)
      @current_user_permissions = current_user.spud_admin_permissions.where(:access => true).all
    end
    def require_user
      unless current_user
        store_location
        flash[:notice] = "You must be logged in to access this page"
        redirect_to new_spud_user_session_url
        return false
      end
      return true
    end

    def require_no_user
      if current_user
        store_location
        flash[:notice] = "You must be logged out to access this page"
        redirect_to root_url
        return false
      end
    end
    
    def store_location
      session[:return_to] = request.url
    end
    
    def redirect_back_or_default(default)
      redirect_to(session[:return_to] || default)
      session[:return_to] = nil
    end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
spud_core-0.7.5 app/controllers/spud/application_controller.rb
spud_core-0.7.4 app/controllers/spud/application_controller.rb
spud_core-0.7.2 app/controllers/spud/application_controller.rb
spud_core-0.7.1 app/controllers/spud/application_controller.rb
spud_core-0.7.0 app/controllers/spud/application_controller.rb
spud_core-0.6.4 app/controllers/spud/application_controller.rb
spud_core-0.6.2 app/controllers/spud/application_controller.rb
spud_core-0.5.6 app/controllers/spud/application_controller.rb
spud_core-0.5.5 app/controllers/spud/application_controller.rb
spud_core-0.5.2 app/controllers/spud/application_controller.rb
spud_core-0.5.1 app/controllers/spud/application_controller.rb
spud_core-0.5.0 app/controllers/spud/application_controller.rb
spud_core-0.4.0 app/controllers/spud/application_controller.rb
spud_admin-0.2.0 app/controllers/spud/application_controller.rb