diff options
author | Stan Hu <stanhu@gmail.com> | 2015-12-27 09:03:06 -0800 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-12-27 09:04:11 -0800 |
commit | 9f7d379c2a018c86671bfc157fe1f0cf4e31e25e (patch) | |
tree | 3b0a9032c050138c3ad9a681f790da9fae65ee51 /app/controllers/registrations_controller.rb | |
parent | a52746649d1db4f52ae4e989dcf654ef4af57905 (diff) | |
download | gitlab-ce-9f7d379c2a018c86671bfc157fe1f0cf4e31e25e.tar.gz |
Add support for Google reCAPTCHA in user registration to prevent spammers
Diffstat (limited to 'app/controllers/registrations_controller.rb')
-rw-r--r-- | app/controllers/registrations_controller.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 3b3dc86cb68..283831f8149 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -1,10 +1,21 @@ class RegistrationsController < Devise::RegistrationsController before_action :signup_enabled? + include Recaptcha::Verify def new redirect_to(new_user_session_path) end + def create + if !Gitlab.config.recaptcha.enabled || verify_recaptcha + super + else + flash[:alert] = "There was an error with the reCAPTCHA code below. Please re-enter the code." + flash.delete :recaptcha_error + render action: 'new' + end + end + def destroy DeleteUserService.new(current_user).execute(current_user) @@ -38,4 +49,16 @@ class RegistrationsController < Devise::RegistrationsController def sign_up_params params.require(:user).permit(:username, :email, :name, :password, :password_confirmation) end + + def resource_name + :user + end + + def resource + @resource ||= User.new + end + + def devise_mapping + @devise_mapping ||= Devise.mappings[:user] + end end |