Class: Gitlab::Auth::OAuth::AuthHash
- Inherits:
-
Object
- Object
- Gitlab::Auth::OAuth::AuthHash
show all
- Defined in:
- lib/gitlab/auth/o_auth/auth_hash.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(auth_hash) ⇒ AuthHash
Returns a new instance of AuthHash.
12
13
14
15
|
# File 'lib/gitlab/auth/o_auth/auth_hash.rb', line 12
def initialize(auth_hash)
@auth_hash = auth_hash
@errors = {}
end
|
Instance Attribute Details
#auth_hash ⇒ Object
Returns the value of attribute auth_hash.
9
10
11
|
# File 'lib/gitlab/auth/o_auth/auth_hash.rb', line 9
def auth_hash
@auth_hash
end
|
#errors ⇒ Object
Returns the value of attribute errors.
10
11
12
|
# File 'lib/gitlab/auth/o_auth/auth_hash.rb', line 10
def errors
@errors
end
|
Instance Method Details
#email ⇒ Object
33
34
35
|
# File 'lib/gitlab/auth/o_auth/auth_hash.rb', line 33
def email
@email ||= username_and_email[:email].to_s
end
|
#has_attribute?(attribute) ⇒ Boolean
50
51
52
53
54
55
56
|
# File 'lib/gitlab/auth/o_auth/auth_hash.rb', line 50
def has_attribute?(attribute)
if attribute == :location
get_info(:address).present?
else
get_info(attribute).present?
end
end
|
#location ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'lib/gitlab/auth/o_auth/auth_hash.rb', line 41
def location
location = get_info(:address)
if location.is_a?(Hash)
[location.locality.presence, location.country.presence].compact.join(', ')
else
location
end
end
|
#name ⇒ Object
25
26
27
|
# File 'lib/gitlab/auth/o_auth/auth_hash.rb', line 25
def name
@name ||= get_info(:name) || "#{get_info(:first_name)} #{get_info(:last_name)}"
end
|
#provider ⇒ Object
21
22
23
|
# File 'lib/gitlab/auth/o_auth/auth_hash.rb', line 21
def provider
@provider ||= auth_hash.provider.to_s
end
|
#uid ⇒ Object
17
18
19
|
# File 'lib/gitlab/auth/o_auth/auth_hash.rb', line 17
def uid
@uid ||= Gitlab::Utils.force_utf8(auth_hash.uid.to_s)
end
|
#username ⇒ Object
29
30
31
|
# File 'lib/gitlab/auth/o_auth/auth_hash.rb', line 29
def username
@username ||= username_and_email[:username].to_s
end
|