summaryrefslogtreecommitdiff
path: root/lib/gitlab/o_auth
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-09-08 10:58:48 +0100
committerDouwe Maan <douwe@gitlab.com>2015-09-08 16:18:14 +0100
commitc915e2c8237ddcae57ec48e700badd9d5bfd8c8c (patch)
tree045b66c46a9af2022734ccf390ccd979f2ddb07a /lib/gitlab/o_auth
parente0da2c352325c1cb2ede88a73434ed7afc037481 (diff)
downloadgitlab-ce-c915e2c8237ddcae57ec48e700badd9d5bfd8c8c.tar.gz
Allow configuration of LDAP attributes GitLab will use for the new user account.
Diffstat (limited to 'lib/gitlab/o_auth')
-rw-r--r--lib/gitlab/o_auth/auth_hash.rb24
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/gitlab/o_auth/auth_hash.rb b/lib/gitlab/o_auth/auth_hash.rb
index 9b8e783d16c..76fbe698c74 100644
--- a/lib/gitlab/o_auth/auth_hash.rb
+++ b/lib/gitlab/o_auth/auth_hash.rb
@@ -16,16 +16,6 @@ module Gitlab
@provider ||= Gitlab::Utils.force_utf8(auth_hash.provider.to_s)
end
- def info
- auth_hash.info
- end
-
- def get_info(key)
- value = info.try(key)
- Gitlab::Utils.force_utf8(value) if value
- value
- end
-
def name
@name ||= get_info(:name) || "#{get_info(:first_name)} #{get_info(:last_name)}"
end
@@ -44,9 +34,21 @@ module Gitlab
private
+ def info
+ auth_hash.info
+ end
+
+ def get_info(key)
+ key = :nickname if key == :username
+
+ value = info[key]
+ Gitlab::Utils.force_utf8(value) if value
+ value
+ end
+
def username_and_email
@username_and_email ||= begin
- username = get_info(:nickname) || get_info(:username)
+ username = get_info(:username)
email = get_info(:email)
username ||= generate_username(email) if email