diff options
author | Patricio Cano <suprnova32@gmail.com> | 2016-04-07 16:45:33 -0500 |
---|---|---|
committer | Patricio Cano <suprnova32@gmail.com> | 2016-04-07 16:45:33 -0500 |
commit | 1d2429af9b0fd4ef1427c7676a50dae4e2cf0ff9 (patch) | |
tree | 664ea18074d0dc82cabd559334c254288023b8c4 /app/controllers/omniauth_callbacks_controller.rb | |
parent | 4361cc395cb5b9574286dee09ac55e49f394e50e (diff) | |
download | gitlab-ce-1d2429af9b0fd4ef1427c7676a50dae4e2cf0ff9.tar.gz |
Add missing proper nil and error handling to SAML login process.
Diffstat (limited to 'app/controllers/omniauth_callbacks_controller.rb')
-rw-r--r-- | app/controllers/omniauth_callbacks_controller.rb | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index d28e96c3f18..df98f56a1cd 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -60,6 +60,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController continue_login_process end + rescue Gitlab::OAuth::SignupDisabledError + handle_signup_error end def omniauth_error @@ -92,16 +94,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController continue_login_process end rescue Gitlab::OAuth::SignupDisabledError - label = Gitlab::OAuth::Provider.label_for(oauth['provider']) - message = "Signing in using your #{label} 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 #{label} account." - end - - flash[:notice] = message - - redirect_to new_user_session_path + handle_signup_error end def handle_service_ticket provider, ticket @@ -122,6 +115,19 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController end end + def handle_signup_error + label = Gitlab::OAuth::Provider.label_for(oauth['provider']) + message = "Signing in using your #{label} 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 #{label} account." + end + + flash[:notice] = message + + redirect_to new_user_session_path + end + def oauth @oauth ||= request.env['omniauth.auth'] end |