Class: NcsNavigator::Authorization::Core::Authority
- Inherits:
-
Object
- Object
- NcsNavigator::Authorization::Core::Authority
- Defined in:
- lib/ncs_navigator/authorization/core/authority.rb
Instance Method Summary collapse
- #amplify!(user) ⇒ Object
- #find_users(*criteria) ⇒ Object
-
#initialize(ignored_config = nil) ⇒ Authority
constructor
A new instance of Authority.
- #user(user) ⇒ Object
Constructor Details
#initialize(ignored_config = nil) ⇒ Authority
Returns a new instance of Authority.
4 5 6 7 8 |
# File 'lib/ncs_navigator/authorization/core/authority.rb', line 4 def initialize(ignored_config=nil) @logger = Logger.new("ncs_navigator_authority_core.log") @groups = {} @portal = :NCSNavigator end |
Instance Method Details
#amplify!(user) ⇒ Object
10 11 12 13 14 |
# File 'lib/ncs_navigator/authorization/core/authority.rb', line 10 def amplify!(user) base = user(user) return user unless base user.merge!(base) end |
#find_users(*criteria) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ncs_navigator/authorization/core/authority.rb', line 42 def find_users(*criteria) return [] unless criteria.empty? result = [] if users = get_users users.each do |u| au = Aker::User.new(u["username"]) au.identifiers[:staff_id] = u["staff_id"] au.first_name = u["first_name"] au.last_name = u["last_name"] result << au end end result end |
#user(user) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ncs_navigator/authorization/core/authority.rb', line 16 def user(user) staff = get_staff(user) if staff u = Aker::User.new(user.username) u.portals << @portal attributes = ["first_name", "last_name", "email"] attributes.each do |a| setter = "#{a}=" if u.respond_to?(setter) u.send(setter, staff[a]) end end u.identifiers[:staff_id] = staff["staff_id"] groups = staff['roles'].collect do |role| role['name'] end if groups u.group_memberships(@portal).concat(load_group_memberships(@portal, groups)) end u else nil end end |