Class: Gitlab::OAuth::AuthHash

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/o_auth/auth_hash.rb

Direct Known Subclasses

LDAP::AuthHash, Saml::AuthHash

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(auth_hash) ⇒ AuthHash

Returns a new instance of AuthHash


7
8
9
# File 'lib/gitlab/o_auth/auth_hash.rb', line 7

def initialize(auth_hash)
  @auth_hash = auth_hash
end

Instance Attribute Details

#auth_hashObject (readonly)

Returns the value of attribute auth_hash


6
7
8
# File 'lib/gitlab/o_auth/auth_hash.rb', line 6

def auth_hash
  @auth_hash
end

Instance Method Details

#emailObject


27
28
29
# File 'lib/gitlab/o_auth/auth_hash.rb', line 27

def email
  @email ||= username_and_email[:email].to_s
end

#has_email?Boolean

Returns:

  • (Boolean)

35
36
37
# File 'lib/gitlab/o_auth/auth_hash.rb', line 35

def has_email?
  get_info(:email).present?
end

#nameObject


19
20
21
# File 'lib/gitlab/o_auth/auth_hash.rb', line 19

def name
  @name ||= get_info(:name) || "#{get_info(:first_name)} #{get_info(:last_name)}"
end

#passwordObject


31
32
33
# File 'lib/gitlab/o_auth/auth_hash.rb', line 31

def password
  @password ||= Gitlab::Utils.force_utf8(Devise.friendly_token[0, 8].downcase)
end

#providerObject


15
16
17
# File 'lib/gitlab/o_auth/auth_hash.rb', line 15

def provider
  @provider ||= Gitlab::Utils.force_utf8(auth_hash.provider.to_s)
end

#uidObject


11
12
13
# File 'lib/gitlab/o_auth/auth_hash.rb', line 11

def uid
  @uid ||= Gitlab::Utils.force_utf8(auth_hash.uid.to_s)
end

#usernameObject


23
24
25
# File 'lib/gitlab/o_auth/auth_hash.rb', line 23

def username
  @username ||= username_and_email[:username].to_s
end