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

Version Path
egov_utils-1.5.0.alpha16 app/services/egov_utils/refresh_groups.rb
egov_utils-1.5.0.alpha15 app/services/egov_utils/refresh_groups.rb
egov_utils-1.5.0.alpha14 app/services/egov_utils/refresh_groups.rb
egov_utils-1.5.0.alpha13 app/services/egov_utils/refresh_groups.rb
egov_utils-1.5.0.alpha12 app/services/egov_utils/refresh_groups.rb
egov_utils-1.5.0.alpha11 app/services/egov_utils/refresh_groups.rb
egov_utils-1.5.0.alpha10 app/services/egov_utils/refresh_groups.rb
egov_utils-1.5.0.alpha9 app/services/egov_utils/refresh_groups.rb
egov_utils-1.5.0.alpha8 app/services/egov_utils/refresh_groups.rb
egov_utils-1.5.0.alpha7 app/services/egov_utils/refresh_groups.rb
egov_utils-1.5.0.alpha6 app/services/egov_utils/refresh_groups.rb
egov_utils-1.5.0.alpha5 app/services/egov_utils/refresh_groups.rb
egov_utils-1.5.0.alpha4 app/services/egov_utils/refresh_groups.rb
egov_utils-1.4.5 app/services/egov_utils/refresh_groups.rb
egov_utils-1.4.4 app/services/egov_utils/refresh_groups.rb
egov_utils-1.5.0.alpha3 app/services/egov_utils/refresh_groups.rb
egov_utils-1.5.0.alpha2 app/services/egov_utils/refresh_groups.rb
egov_utils-1.5.0.alpha1 app/services/egov_utils/refresh_groups.rb
egov_utils-1.4.3 app/services/egov_utils/refresh_groups.rb
egov_utils-1.4.2 app/services/egov_utils/refresh_groups.rb