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
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
......
......@@ -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
......
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