diff --git a/Gemfile b/Gemfile
index 5ce666f0..fbf7845a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -119,3 +119,6 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'coveralls', require: false
gem 'random_password'
+
+# Adds helpers for the Google reCAPTCHA API
+gem "recaptcha"
diff --git a/Gemfile.lock b/Gemfile.lock
index 88d24127..3bcd53c3 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -220,6 +220,8 @@ GEM
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
+ recaptcha (4.14.0)
+ json
redcarpet (3.4.0)
redis (3.3.5)
remote_syslog_logger (1.0.4)
@@ -363,6 +365,7 @@ DEPENDENCIES
rails (~> 5.0.7)
rails-controller-testing
random_password
+ recaptcha
redcarpet
redis (~> 3.0)
remote_syslog_logger
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index a7517e01..2e1039dc 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -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
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 4a354368..e2cae8e6 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -17,4 +17,7 @@
# with BigBlueButton; if not, see