From f60eb60473a1dcfd2b874d5ebac6dca60da7c1ea Mon Sep 17 00:00:00 2001 From: Patricio Cano Date: Tue, 22 Sep 2015 16:26:59 -0500 Subject: Added ability to update or set the identity of an existing user, like the documentation said it was possible, but actually wasn't. --- lib/api/users.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/api/users.rb') 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 -- cgit v1.2.1