Class: Gitlab::Auth::OmniauthIdentityLinkerBase

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/auth/omniauth_identity_linker_base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_user, oauth, session = {}) ⇒ OmniauthIdentityLinkerBase

Returns a new instance of OmniauthIdentityLinkerBase.



8
9
10
11
12
13
# File 'lib/gitlab/auth/omniauth_identity_linker_base.rb', line 8

def initialize(current_user, oauth, session = {})
  @current_user = current_user
  @oauth = oauth
  @changed = false
  @session = session
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.



6
7
8
# File 'lib/gitlab/auth/omniauth_identity_linker_base.rb', line 6

def current_user
  @current_user
end

#oauthObject (readonly)

Returns the value of attribute oauth.



6
7
8
# File 'lib/gitlab/auth/omniauth_identity_linker_base.rb', line 6

def oauth
  @oauth
end

#sessionObject (readonly)

Returns the value of attribute session.



6
7
8
# File 'lib/gitlab/auth/omniauth_identity_linker_base.rb', line 6

def session
  @session
end

Instance Method Details

#authorization_required?Boolean

Require user authorization to link identity. False by default, enabled in specific subclasses.

Returns:

  • (Boolean)


29
30
31
# File 'lib/gitlab/auth/omniauth_identity_linker_base.rb', line 29

def authorization_required?
  false
end

#changed?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/gitlab/auth/omniauth_identity_linker_base.rb', line 19

def changed?
  @changed
end

#error_messageObject



33
34
35
36
37
# File 'lib/gitlab/auth/omniauth_identity_linker_base.rb', line 33

def error_message
  identity.validate

  identity.errors.full_messages.join(', ')
end

#failed?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/gitlab/auth/omniauth_identity_linker_base.rb', line 23

def failed?
  error_message.present?
end


15
16
17
# File 'lib/gitlab/auth/omniauth_identity_linker_base.rb', line 15

def link
  save if unlinked?
end

#providerObject



39
40
41
# File 'lib/gitlab/auth/omniauth_identity_linker_base.rb', line 39

def provider
  oauth['provider']
end

#uidObject



43
44
45
# File 'lib/gitlab/auth/omniauth_identity_linker_base.rb', line 43

def uid
  oauth['uid']
end