summaryrefslogtreecommitdiff
path: root/lib/gitlab/auth/o_auth
diff options
context:
space:
mode:
authorJames Edwards-Jones <jedwardsjones@gitlab.com>2018-04-22 19:08:08 +0100
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2018-04-22 23:50:56 +0100
commitf8d54913bb6f846d1204704d3a6e457956461b35 (patch)
tree7541e607f0e77638411448cf42482ee3ba778cf7 /lib/gitlab/auth/o_auth
parentf10c999bca2b5b37b068ff3680a6e35a6707828d (diff)
downloadgitlab-ce-f8d54913bb6f846d1204704d3a6e457956461b35.tar.gz
Show error on failed OAuth account link
Diffstat (limited to 'lib/gitlab/auth/o_auth')
-rw-r--r--lib/gitlab/auth/o_auth/identity_linker.rb20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/gitlab/auth/o_auth/identity_linker.rb b/lib/gitlab/auth/o_auth/identity_linker.rb
index cfa83ba2a55..704a7e1b3c2 100644
--- a/lib/gitlab/auth/o_auth/identity_linker.rb
+++ b/lib/gitlab/auth/o_auth/identity_linker.rb
@@ -3,11 +3,23 @@ module Gitlab
module OAuth
class IdentityLinker < OmniauthIdentityLinkerBase
def create_or_update
- current_user.identities
- .with_extern_uid(oauth['provider'], oauth['uid'])
- .first_or_create(extern_uid: oauth['uid'])
+ if identity.new_record?
+ @created = identity.save
+ end
+ end
+
+ def error_message
+ identity.validate
+
+ identity.errors.full_messages.join(', ')
+ end
+
+ private
- @created = true
+ def identity
+ @identity ||= current_user.identities
+ .with_extern_uid(oauth['provider'], oauth['uid'])
+ .first_or_initialize(extern_uid: oauth['uid'])
end
end
end