diff options
author | Drew Blessing <drew@gitlab.com> | 2017-01-03 01:08:21 -0600 |
---|---|---|
committer | Drew Blessing <drew@gitlab.com> | 2017-01-03 01:35:42 -0600 |
commit | ca1c492bafa024ad4c185e930af57e1f8090ca77 (patch) | |
tree | e193e6b02c2abef0d9c830e2230f047f6fadf2d2 /app | |
parent | de25604fbca2f7005754d821d571bbcb1cc510ac (diff) | |
download | gitlab-ce-ca1c492bafa024ad4c185e930af57e1f8090ca77.tar.gz |
Properly handle failed reCAPTCHA on user registration
If a user presses the 'Register' button too quickly after attempting
to solve the reCAPTCHA, or the reCAPTCHA is not solved at all, the
user would experience a 500 error. Now, the case is properly
handled and the user will be sent back to the registration page
with a clear error message and can try again.
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/registrations_controller.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index c45196cc3e9..a16dbb20cdf 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -7,17 +7,17 @@ class RegistrationsController < Devise::RegistrationsController end def create - if !Gitlab::Recaptcha.load_configurations! || verify_recaptcha - # To avoid duplicate form fields on the login page, the registration form - # names fields using `new_user`, but Devise still wants the params in - # `user`. - if params["new_#{resource_name}"].present? && params[resource_name].blank? - params[resource_name] = params.delete(:"new_#{resource_name}") - end + # To avoid duplicate form fields on the login page, the registration form + # names fields using `new_user`, but Devise still wants the params in + # `user`. + if params["new_#{resource_name}"].present? && params[resource_name].blank? + params[resource_name] = params.delete(:"new_#{resource_name}") + end + if !Gitlab::Recaptcha.load_configurations! || verify_recaptcha super else - flash[:alert] = "There was an error with the reCAPTCHA code below. Please re-enter the code." + flash[:alert] = 'There was an error with the reCAPTCHA. Please re-solve the reCAPTCHA.' flash.delete :recaptcha_error render action: 'new' end |