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

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