GRN2-125: Added a configurable reCAPTCHA on sign up (#502)

* Added a configurable reCAPTCHA on sign up

* Added missing code
This commit is contained in:
farhatahmad
2019-05-07 09:21:04 -04:00
committed by Jesus Federico
parent f6dd3d34eb
commit 75f48f4979
8 changed files with 39 additions and 3 deletions

View File

@ -31,8 +31,15 @@ class UsersController < ApplicationController
@user = User.new(user_params)
@user.provider = @user_domain
# Handle error on user creation.
render(:new) && return unless @user.save
# Add validation errors to model if they exist
valid_user = @user.valid?
valid_captcha = config.recaptcha_enabled ? verify_recaptcha(model: @user) : true
if valid_user && valid_captcha
@user.save
else
render(:new) && return
end
# Sign in automatically if email verification is disabled.
login(@user) && return unless Rails.configuration.enable_email_verification