Commit 17a41547 authored by Douwe Maan's avatar Douwe Maan

Improve OAuth signup error message.

parent 9eb45ccd
...@@ -65,8 +65,15 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController ...@@ -65,8 +65,15 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
redirect_to omniauth_error_path(oauth['provider'], error: error_message) and return redirect_to omniauth_error_path(oauth['provider'], error: error_message) and return
end end
end end
rescue Gitlab::OAuth::ForbiddenAction => e rescue Gitlab::OAuth::SignupDisabledError => e
flash[:notice] = e.message 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 redirect_to new_user_session_path
end end
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# #
module Gitlab module Gitlab
module OAuth module OAuth
class ForbiddenAction < StandardError; end class SignupDisabledError < StandardError; end
class User class User
attr_accessor :auth_hash, :gl_user attr_accessor :auth_hash, :gl_user
...@@ -99,7 +99,7 @@ module Gitlab ...@@ -99,7 +99,7 @@ module Gitlab
end end
def unauthorized_to_create def unauthorized_to_create
raise ForbiddenAction.new("Unauthorized to create user, signup disabled for #{auth_hash.provider}") raise SignupDisabledError
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment