summaryrefslogtreecommitdiff
path: root/app/controllers/omniauth_callbacks_controller.rb
diff options
context:
space:
mode:
authorMarin Jankovski <marin@gitlab.com>2014-06-24 12:57:41 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-24 15:30:29 +0300
commitf40e87a03bdaaafa72e5afede57581d6c54dc506 (patch)
treed15c139f229541106b98373a8b04e5d67dfdd311 /app/controllers/omniauth_callbacks_controller.rb
parent2d9667df264dae9a11fe58f8320a716d61e48e06 (diff)
downloadgitlab-ce-f40e87a03bdaaafa72e5afede57581d6c54dc506.tar.gz
Return better error when account exists when attempting oauth account create.
Diffstat (limited to 'app/controllers/omniauth_callbacks_controller.rb')
-rw-r--r--app/controllers/omniauth_callbacks_controller.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb
index 0c87fe0d9ae..477743b34c8 100644
--- a/app/controllers/omniauth_callbacks_controller.rb
+++ b/app/controllers/omniauth_callbacks_controller.rb
@@ -45,14 +45,19 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
# Create user if does not exist
# and allow_single_sign_on is true
- if Gitlab.config.omniauth['allow_single_sign_on']
- @user ||= Gitlab::OAuth::User.create(oauth)
+ if Gitlab.config.omniauth['allow_single_sign_on'] && !@user
+ @user, errors = Gitlab::OAuth::User.create(oauth)
end
- if @user
+ if @user && !errors
sign_in_and_redirect(@user)
else
- flash[:notice] = "There's no such user!"
+ if errors
+ error_message = errors.map{ |attribute, message| "#{attribute} #{message}" }.join(", ")
+ flash[:notice] = "There was a problem creating your account. #{error_message}"
+ else
+ flash[:notice] = "There's no such user!"
+ end
redirect_to new_user_session_path
end
end