diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-05-12 12:50:06 +0200 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-05-13 09:41:56 +0200 |
commit | 17a41547a038fd2ecb8b00499541861383927344 (patch) | |
tree | 426c9a33bc55ac5d77ab8c27ecde1f4e398c12fd | |
parent | 9eb45ccd552c7c0a3c2104f01e86120d7c9f4060 (diff) | |
download | gitlab-ce-17a41547a038fd2ecb8b00499541861383927344.tar.gz |
Improve OAuth signup error message.
-rw-r--r-- | app/controllers/omniauth_callbacks_controller.rb | 11 | ||||
-rw-r--r-- | lib/gitlab/o_auth/user.rb | 4 |
2 files changed, 11 insertions, 4 deletions
diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index bb9d65c9ed6..dcd949a71de 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -65,8 +65,15 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController redirect_to omniauth_error_path(oauth['provider'], error: error_message) and return end end - rescue Gitlab::OAuth::ForbiddenAction => e - flash[:notice] = e.message + rescue Gitlab::OAuth::SignupDisabledError => e + message = "Signing in using your #{oauth['provider']} account without a pre-existing GitLab account is not allowed." + + if current_application_settings.signup_enabled? + message << " Create a GitLab account first, and then connect it to your #{oauth['provider']} account." + end + + flash[:notice] = message + redirect_to new_user_session_path end diff --git a/lib/gitlab/o_auth/user.rb b/lib/gitlab/o_auth/user.rb index 2f5c217d764..ba5caed6131 100644 --- a/lib/gitlab/o_auth/user.rb +++ b/lib/gitlab/o_auth/user.rb @@ -5,7 +5,7 @@ # module Gitlab module OAuth - class ForbiddenAction < StandardError; end + class SignupDisabledError < StandardError; end class User attr_accessor :auth_hash, :gl_user @@ -99,7 +99,7 @@ module Gitlab end def unauthorized_to_create - raise ForbiddenAction.new("Unauthorized to create user, signup disabled for #{auth_hash.provider}") + raise SignupDisabledError end end end |