Class: OrangeUser

Inherits:
Orange::Carton show all
Defined in:
lib/orange-more/administration/cartons/user.rb

Instance Method Summary collapse

Methods inherited from Orange::Carton

asset

Instance Method Details

#allowed?(packet) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/orange-more/administration/cartons/user.rb', line 12

def allowed?(packet)
  subsite_access = packet['subsite'].blank? ? false : self.orange_sites.first(:id => packet['subsite'].id)
  site_access = self.orange_sites.first(:id => packet['site'].id)
  if(!site_access.blank?)
    true
  elsif !packet['subsite'].blank? && subsite_access
    true
  else  
    # nil out invalid user
    packet.session['user.id'] = nil
    packet['user.id'] = nil
    false
  end
end