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

#changed?Boolean

Returns:

  • (Boolean)


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

def changed?
  @changed
end

#error_messageObject



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

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