Sha256: dd29444e99dc34f8e26c62cd48a2b81b7cdeb21da4ada4efddfb6210963f0c77

Contents?: true

Size: 750 Bytes

Versions: 14

Compression:

Stored size: 750 Bytes

Contents

class GuestUser < User
  
  def initialize(attributes={})
    super({:login => "guest", :first_name => "Anonymous", :last_name => "User"}.merge(attributes))
    @guest = true
  end
    
  def able_to?(*name)
    group && group.permissions.count(:conditions => ["name in (?)", name.map(&:to_s)]) > 0
  end
  
  def able_to_view?(page)
    group && !!(group.sections.include?(page.section))
  end
  
  def able_to_edit?(section)
    false
  end
  
  def group
    @group ||= Group.find_by_code("guest")
  end
  
  def groups
    [group]
  end
  
  #You shouldn't be able to save a guest user
  def update_attribute(name, value)
    false
  end
  def update_attributes(attrs={})
    false
  end
  def save(perform_validation=true)
    false
  end
  
end

Version data entries

14 entries across 14 versions & 7 rubygems

Version Path
SFEley-browsercms-3.0.2 app/models/guest_user.rb
buzzware-browsercms-3.0.2 app/models/guest_user.rb
coredumplings-browsercms-3.0.0 app/models/guest_user.rb
we5-browsercms-3.0.1.1 app/models/guest_user.rb
webficient-browsercms-3.0.1 app/models/guest_user.rb
webficient-browsercms-3.0.2 app/models/guest_user.rb
webficient-browsercms-3.0.3 app/models/guest_user.rb
webficient-browsercms-3.0.4 app/models/guest_user.rb
browsercms_s3-3.0.4 app/models/guest_user.rb
browsercms_s3-3.0.3 app/models/guest_user.rb
we5-browsercms-3.0.2 app/models/guest_user.rb
browsercms-3.0.2 app/models/guest_user.rb
browsercms-3.0.1 app/models/guest_user.rb
browsercms-3.0.0 app/models/guest_user.rb