Sha256: 26d9f993ca884f4fa796549c01a0738f7891c39aeca0e464dd60e908bcc89d44
Contents?: true
Size: 638 Bytes
Versions: 27
Compression:
Stored size: 638 Bytes
Contents
module EgovUtils class RefreshUserGroups def initialize(user) @user = user end def call group_ids = (current_non_ldap_groups + ldap_groups).compact.map(&:id) user.group_ids = group_ids user end private attr_reader :user def ldap_groups return [] if user.provider.blank? @ldap_groups ||= EgovUtils::Group.where(provider: user.provider).to_a.select do |g| user.auth_source.member?(user.ldap_dn, g.external_uid) end end def current_non_ldap_groups @current_non_ldap_groups ||= user.groups.where(ldap_uid: nil) end end end
Version data entries
27 entries across 27 versions & 1 rubygems