lib/socialcast/net_ldap_ext.rb in socialcast-1.0.6 vs lib/socialcast/net_ldap_ext.rb in socialcast-1.0.7
- old
+ new
@@ -34,18 +34,23 @@
end
end
membership_attribute = permission_mappings.fetch 'attribute_name', 'memberof'
memberships = self[membership_attribute]
- external_ldap_group = permission_mappings.fetch('account_types', {})['external']
- if external_ldap_group && memberships.include?(external_ldap_group)
+ external_ldap_groups = Array.wrap(permission_mappings.fetch('account_types', {})['external'])
+ if external_ldap_groups.any? { |external_ldap_group| memberships.include?(external_ldap_group) }
user.tag! 'account-type', 'external'
else
user.tag! 'account-type', 'member'
if permission_roles_mappings = permission_mappings['roles']
user.tag! 'roles', :type => 'array' do |roles|
- permission_roles_mappings.each_pair do |socialcast_role, ldap_group|
- roles.role socialcast_role if memberships.include?(ldap_group)
+ permission_roles_mappings.each_pair do |socialcast_role, ldap_groups|
+ Array.wrap(ldap_groups).each do |ldap_group|
+ if memberships.include?(ldap_group)
+ roles.role socialcast_role
+ break
+ end
+ end
end
end
end
end
end