Sha256: 4cd19346d321baf73cc1c5de3f377dcf0e3e633f5ddd1d8ab5b55429979f83f7
Contents?: true
Size: 730 Bytes
Versions: 23
Compression:
Stored size: 730 Bytes
Contents
module EgovUtils class RefreshGroups def call hsh = remote_groups.each_with_object({}) do |group, memo| infos = group.ldap_members infos.each do |info| memo[info] ||= [] memo[info] << group end end hsh.each do |info, groups| user = EgovUtils::User.where("login ILIKE ?", info[:login]).first next unless user all_groups = user.groups.where(ldap_uid: nil) + groups info[:login] = info[:login].downcase info[:mail] = info[:mail].downcase user.update(info.except(:dn).merge(groups: all_groups)) end end private def remote_groups EgovUtils::Group.where.not(ldap_uid: nil) end end end
Version data entries
23 entries across 23 versions & 1 rubygems