Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Edwards-Jones <jedwardsjones@gitlab.com>2018-04-23 13:56:44 +0300
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2018-04-23 15:53:32 +0300
commitd3a8a07423dccf1709b6432e017ae4679143dbce (patch)
tree0555fa8871e274eee93d38cd7bbbd79a5718142d /lib/gitlab/auth/omniauth_identity_linker_base.rb
parentf8d54913bb6f846d1204704d3a6e457956461b35 (diff)
Unify Saml::IdentityLinker and OAuth::IdentityLinker
Diffstat (limited to 'lib/gitlab/auth/omniauth_identity_linker_base.rb')
-rw-r--r--lib/gitlab/auth/omniauth_identity_linker_base.rb34
1 files changed, 28 insertions, 6 deletions
diff --git a/lib/gitlab/auth/omniauth_identity_linker_base.rb b/lib/gitlab/auth/omniauth_identity_linker_base.rb
index 4ed28d6a8be..ae365fcdfaa 100644
--- a/lib/gitlab/auth/omniauth_identity_linker_base.rb
+++ b/lib/gitlab/auth/omniauth_identity_linker_base.rb
@@ -6,19 +6,41 @@ module Gitlab
def initialize(current_user, oauth)
@current_user = current_user
@oauth = oauth
- @created = false
+ @changed = false
end
- def created?
- @created
+ def link
+ save if identity.new_record?
+ end
+
+ def changed?
+ @changed
end
def error_message
- ''
+ identity.validate
+
+ identity.errors.full_messages.join(', ')
+ end
+
+ private
+
+ def save
+ @changed = identity.save
+ end
+
+ def identity
+ @identity ||= current_user.identities
+ .with_extern_uid(provider, uid)
+ .first_or_initialize(extern_uid: uid)
+ end
+
+ def provider
+ oauth['provider']
end
- def create_or_update
- raise NotImplementedError
+ def uid
+ oauth['uid']
end
end
end