diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-09-22 23:58:24 -0700 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-09-22 23:58:24 -0700 |
commit | 0630be3828998af1261b87ae85b42c0ef9a439ed (patch) | |
tree | 312a70ff94c1abb585b798b9f41698026e388a77 /lib | |
parent | 089f0000cae2d49aa7f031e628a6d9e66db69fec (diff) | |
parent | 8a8123a3d4d3a5f991ae599e454b99fd548d47f2 (diff) | |
download | gitlab-ce-0630be3828998af1261b87ae85b42c0ef9a439ed.tar.gz |
Merge pull request #5063 from karlhungus/feature-allow-ldap-update-with-username
Allows username only updates to ldap properties
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ldap/user.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/gitlab/ldap/user.rb b/lib/gitlab/ldap/user.rb index c8f3a69376a..260bacfeeb0 100644 --- a/lib/gitlab/ldap/user.rb +++ b/lib/gitlab/ldap/user.rb @@ -26,7 +26,7 @@ module Gitlab # * When user already has account and need to link his LDAP account. # * LDAP uid changed for user with same email and we need to update his uid # - user = model.find_by_email(email) + user = find_user(email) if user user.update_attributes(extern_uid: uid, provider: provider) @@ -43,6 +43,19 @@ module Gitlab user end + def find_user(email) + user = model.find_by_email(email) + + # If no user found and allow_username_or_email_login is true + # we look for user by extracting part of his email + if !user && email && ldap_conf['allow_username_or_email_login'] + uname = email.partition('@').first + user = model.find_by_username(uname) + end + + user + end + def authenticate(login, password) # Check user against LDAP backend if user is not authenticated # Only check with valid login and password to prevent anonymous bind results |