diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-01-30 00:28:41 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-01-30 00:28:41 +0300 |
commit | ca701a964971a3291270e60669757c9853e3cf66 (patch) | |
tree | ef10b8967df7ca2fbf31bc879e7bef92cbf22bd8 /lib/gitlab/ldap/user.rb | |
parent | d54f80980432d781b8730c672576e5e47620f502 (diff) |
Improvements to LDAP::User model
* method #changed? also tracks changes of identites (fixes issue with email mapping)
* find ldap identity before initialize one
Diffstat (limited to 'lib/gitlab/ldap/user.rb')
-rw-r--r-- | lib/gitlab/ldap/user.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/gitlab/ldap/user.rb b/lib/gitlab/ldap/user.rb index 3ef494ba137..cfa8692659d 100644 --- a/lib/gitlab/ldap/user.rb +++ b/lib/gitlab/ldap/user.rb @@ -40,12 +40,16 @@ module Gitlab def update_user_attributes gl_user.email = auth_hash.email - gl_user.identities.build(provider: auth_hash.provider, extern_uid: auth_hash.uid) + + # 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) + gl_user end def changed? - gl_user.changed? + gl_user.changed? || gl_user.identities.any?(&:changed?) end def needs_blocking? |