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
path: root/lib/api
diff options
context:
space:
mode:
authorPatricio Cano <suprnova32@gmail.com>2015-09-23 00:26:59 +0300
committerPatricio Cano <suprnova32@gmail.com>2015-09-23 00:26:59 +0300
commitf60eb60473a1dcfd2b874d5ebac6dca60da7c1ea (patch)
tree863c43ad056482e10c2e3ece4f5aecffd9cc424e /lib/api
parente0a23791d3cdf7a72e974acc79c3755b35f2da79 (diff)
Added ability to update or set the identity of an existing user, like the documentation said it was possible, but actually wasn't.
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/users.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb
index 813cc379e43..a98d668e02d 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -121,6 +121,17 @@ module API
User.where(username: attrs[:username]).
where.not(id: user.id).count > 0
+ identity_attrs = attributes_for_keys [:provider, :extern_uid]
+ if identity_attrs.any?
+ identity = user.identities.find_by(provider: identity_attrs[:provider])
+ if identity
+ identity.update_attributes(identity_attrs)
+ else
+ identity = user.identities.build(identity_attrs)
+ identity.save
+ end
+ end
+
if user.update_attributes(attrs)
present user, with: Entities::UserFull
else