Sha256: 168dba5ba414e4c8540814fa85350fae084cbaf5c4b5702b759d8facc3110c1c

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

module Lockdown
  module Session
    def nil_lockdown_values
      [:expiry_time, :user_id, :user_name, :user_profile_id, :access_rights].each do |val|
        session[val] = nil if session[val]
      end
    end 
    
    def current_user_access_in_group?(grp)
      return true if current_user_is_admin?
        Lockdown::System.user_groups[grp].each do |perm|
          return true if access_in_perm?(perm)
        end
      false
    end

    def current_user_is_admin?
      session[:access_rights] == :all
    end

    private

    def add_lockdown_session_values(user)
      session[:access_rights] = Lockdown::System.access_rights_for_user(user)
    end

    def access_in_perm?(perm)
      Lockdown::System.permissions[perm].each do |ar|
        return true if session_access_rights_include?(ar)
      end unless Lockdown::System.permissions[perm].nil?
      false
    end

    def session_access_rights_include?(str)
      return false unless session[:access_rights]
      session[:access_rights].include?(str)
    end
  end # Session
end # Lockdown

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lockdown-0.6.1 lib/lockdown/session.rb
lockdown-0.6.0 lib/lockdown/session.rb
lockdown-0.6.2 lib/lockdown/session.rb
lockdown-0.6.3 lib/lockdown/session.rb
lockdown-0.7.0 lib/lockdown/session.rb
lockdown-0.7.1 lib/lockdown/session.rb