summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-09-09 11:40:31 +0100
committerDouwe Maan <douwe@gitlab.com>2015-09-09 11:40:31 +0100
commit909a8443c63db423f031b8c7f810c13b3bc20b87 (patch)
tree407a473ad47c92a98f8b21891ad57731ce58f2bc
parent9c6ed296640ff06d5ae078024f112e44910af235 (diff)
downloadgitlab-ce-909a8443c63db423f031b8c7f810c13b3bc20b87.tar.gz
Shuffle config around a bit
-rw-r--r--lib/gitlab/ldap/auth_hash.rb13
-rw-r--r--lib/gitlab/ldap/user.rb7
-rw-r--r--lib/gitlab/o_auth/auth_hash.rb4
3 files changed, 9 insertions, 15 deletions
diff --git a/lib/gitlab/ldap/auth_hash.rb b/lib/gitlab/ldap/auth_hash.rb
index caca7bb3b57..dc8a8fd41dd 100644
--- a/lib/gitlab/ldap/auth_hash.rb
+++ b/lib/gitlab/ldap/auth_hash.rb
@@ -3,17 +3,10 @@
module Gitlab
module LDAP
class AuthHash < Gitlab::OAuth::AuthHash
- attr_accessor :config
-
- def initialize(auth_hash, config)
- super(auth_hash)
- @config = config
- end
-
private
def get_info(key)
- raw_key = config.attributes[key]
+ raw_key = ldap_config.attributes[key]
return super unless raw_key
value =
@@ -35,6 +28,10 @@ module Gitlab
def get_raw(key)
auth_hash.extra[:raw_info][key]
end
+
+ def ldap_config
+ @ldap_config ||= Gitlab::LDAP::Config.new(self.provider)
+ end
end
end
end
diff --git a/lib/gitlab/ldap/user.rb b/lib/gitlab/ldap/user.rb
index e5023f5da11..cb66fd500fe 100644
--- a/lib/gitlab/ldap/user.rb
+++ b/lib/gitlab/ldap/user.rb
@@ -68,13 +68,12 @@ module Gitlab
Gitlab::LDAP::Access.allowed?(gl_user)
end
- def ldap_config(provider = auth_hash.provider)
- Gitlab::LDAP::Config.new(provider)
+ def ldap_config
+ Gitlab::LDAP::Config.new(auth_hash.provider)
end
def auth_hash=(auth_hash)
- config = ldap_config(auth_hash.provider)
- @auth_hash = Gitlab::LDAP::AuthHash.new(auth_hash, config)
+ @auth_hash = Gitlab::LDAP::AuthHash.new(auth_hash)
end
end
end
diff --git a/lib/gitlab/o_auth/auth_hash.rb b/lib/gitlab/o_auth/auth_hash.rb
index 76fbe698c74..d94b104bbf8 100644
--- a/lib/gitlab/o_auth/auth_hash.rb
+++ b/lib/gitlab/o_auth/auth_hash.rb
@@ -39,8 +39,6 @@ module Gitlab
end
def get_info(key)
- key = :nickname if key == :username
-
value = info[key]
Gitlab::Utils.force_utf8(value) if value
value
@@ -48,7 +46,7 @@ module Gitlab
def username_and_email
@username_and_email ||= begin
- username = get_info(:username)
+ username = get_info(:username) || get_info(:nickname)
email = get_info(:email)
username ||= generate_username(email) if email