Class: EgovUtils::Group

Inherits:
Principal show all
Defined in:
app/models/egov_utils/group.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Principal

#auth_source, #has_role?, #ldap?, #ldap_domain, #organization_by_domain, #organization_id, #organization_id_by_key, #organization_key, #organization_with_suborganizations_ids, #organization_with_suborganizations_keys, #reload

Class Method Details

.organizations_by_domains(domains) ⇒ Object



10
11
12
# File 'app/models/egov_utils/group.rb', line 10

def self.organizations_by_domains(domains)
  EgovUtils::Organization.where(domain: domains)
end

Instance Method Details

#allow_member_assign?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/models/egov_utils/group.rb', line 14

def allow_member_assign?
  provider.nil?
end

#external_uidObject



38
39
40
# File 'app/models/egov_utils/group.rb', line 38

def external_uid
  super || ( ldap? && ldap_uid && auth_source.send(:get_group_dn, sid: ldap_uid) )
end

#ldap_dnObject



42
43
44
# File 'app/models/egov_utils/group.rb', line 42

def ldap_dn
  ldap? && external_uid
end

#ldap_member?(user) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'app/models/egov_utils/group.rb', line 34

def ldap_member?(user)
  ldap_members.detect{|mem| mem[:login] == user. }
end

#ldap_membersObject



26
27
28
29
30
31
32
# File 'app/models/egov_utils/group.rb', line 26

def ldap_members
  if provider.present?
    auth_source.group_members(ldap_dn)
  else
    []
  end
end

#membersObject



18
19
20
21
22
23
24
# File 'app/models/egov_utils/group.rb', line 18

def members
  if ldap?
    EgovUtils::User.where(login: ldap_members.collect{|m| m[:login] })
  else
    users
  end
end