diff options
author | Joel Koglin <JoelKoglin@gmail.com> | 2015-07-22 00:03:26 +0300 |
---|---|---|
committer | Joel Koglin <Joel.Koglin@concur.com> | 2015-08-21 19:36:27 +0300 |
commit | 4d2f36118a3b21b6bb4ee702b98d032967ba463a (patch) | |
tree | d2e2093d48b7bc5a38a9c3d1ea85ad7a5904c492 /lib/gitlab/ldap/user.rb | |
parent | f5b3bf84ad10a03c58c161e84ef919661c84267c (diff) |
Issue #993: Fixed login failure when extern_uid changes
Diffstat (limited to 'lib/gitlab/ldap/user.rb')
-rw-r--r-- | lib/gitlab/ldap/user.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/gitlab/ldap/user.rb b/lib/gitlab/ldap/user.rb index f7f3ba9ad7d..2ffb1241966 100644 --- a/lib/gitlab/ldap/user.rb +++ b/lib/gitlab/ldap/user.rb @@ -44,9 +44,13 @@ module Gitlab gl_user.skip_reconfirmation! gl_user.email = auth_hash.email - # Build new identity only if we dont have have same one - gl_user.identities.find_or_initialize_by(provider: auth_hash.provider, - extern_uid: auth_hash.uid) + # If we don't have an identity for this provider yet, create one + if gl_user.identities.find_by(provider: auth_hash.provider).nil? + gl_user.identities.new(extern_uid: auth_hash.uid, provider: auth_hash.provider) + else # Update the UID attribute for this provider in case it has changed + identity = gl_user.identities.select { |identity| identity.provider == auth_hash.provider } + identity.first.extern_uid = auth_hash.uid + end gl_user end |