Project

General

Profile

foreman-cern-issue32466-ldap-users-as-external.patch

Nacho Barrientos, 05/17/2021 12:09 PM

View differences:

app/models/user.rb
317 317

  
318 318
    # existing user, we'll update them
319 319
    if (user = unscoped.find_by_login(attrs[:login]))
320
      unless user.auth_source.is_a? AuthSourceExternal
320
      unless user.auth_source.is_a? AuthSourceExternal or user.auth_source.is_a? AuthSourceLdap
321 321
        logger.info "Failed to log in external user: Username '#{attrs[:login]}' already exists in a different authentication source"
322 322
        return nil
323 323
      end
324 324
      # we know this auth source and it's user's auth source, we'll update user attributes
325
      if auth_source && (user.auth_source_id == auth_source.id)
325
      if auth_source && (user.auth_source.is_a? AuthSourceExternal) && (user.auth_source_id == auth_source.id)
326 326
        auth_source_external_groups = auth_source.external_usergroups.pluck(:usergroup_id)
327 327
        new_usergroups = user.usergroups.includes(:external_usergroups).where.not('usergroups.id' => auth_source_external_groups)
328 328