Improve OAuth signup error message.
This commit is contained in:
parent
9eb45ccd55
commit
17a41547a0
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue