Skip to content
Snippets Groups Projects
Commit 8c881fd1 authored by Douwe Maan's avatar Douwe Maan
Browse files

Improve OAuth signup error message.

parent 4a17bee7
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
 
Loading
Loading
Loading
Loading
@@ -5,7 +5,7 @@
#
module Gitlab
module OAuth
class ForbiddenAction < StandardError; end
class SignupDisabledError < StandardError; end
 
class User
attr_accessor :auth_hash, :gl_user
Loading
Loading
@@ -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
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment