Sha256: b91224e84c3209a3bf579e3f0e7636e2f05edd1015d1e8e8f0646c348dfeadd9
Contents?: true
Size: 785 Bytes
Versions: 1
Compression:
Stored size: 785 Bytes
Contents
module EgovUtils class RefreshUserGroups def initialize(user) @user = user end def call group_ids = (current_non_ldap_group + ldap_groups).compact.map(&:id) user.group_ids = group_ids user end private attr_reader :user def ldap_dn @ldap_dn ||= begin dn = user.auth_source.send(:get_user_dn, user.login) dn[:dn] if dn end end def ldap_groups return [] if user.provider.blank? @ldap_groups ||= begin EgovUtils::Group.where(provider: provider).to_a.select do |g| user.auth_source.member?(ldap_dn, g.external_uid) end end end def current_non_ldap_group @current_non_ldap_groups ||= user.groups.where(ldap_uid: nil) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
egov_utils-1.0.0 | app/services/egov_utils/refresh_user_groups.rb |