summaryrefslogtreecommitdiff
path: root/app/controllers/registrations_controller.rb
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2019-06-25 22:32:54 +0000
committerThong Kuah <tkuah@gitlab.com>2019-06-25 22:32:54 +0000
commit15e9aced75319e6e2b48f4b19fcba1346103f772 (patch)
tree6ff0d9fa36aa2e67e565147fd5105f90fe5a6a11 /app/controllers/registrations_controller.rb
parent87b468c254e3e1e3b6b1d86e003f1f90a39935a2 (diff)
downloadgitlab-ce-15e9aced75319e6e2b48f4b19fcba1346103f772.tar.gz
New RecaptchaExperimentHelper modules
RecaptchaExperimentHelper contains helper methods to assist in the controller and view layers.
Diffstat (limited to 'app/controllers/registrations_controller.rb')
-rw-r--r--app/controllers/registrations_controller.rb30
1 files changed, 20 insertions, 10 deletions
diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb
index 07b38371ab9..b2b151bbcf0 100644
--- a/app/controllers/registrations_controller.rb
+++ b/app/controllers/registrations_controller.rb
@@ -3,6 +3,7 @@
class RegistrationsController < Devise::RegistrationsController
include Recaptcha::Verify
include AcceptsPendingInvitations
+ include RecaptchaExperimentHelper
prepend_before_action :check_captcha, only: :create
before_action :whitelist_query_limiting, only: [:destroy]
@@ -15,13 +16,6 @@ class RegistrationsController < Devise::RegistrationsController
end
def create
- # 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
-
accept_pending_invitations
super do |new_user|
@@ -74,19 +68,35 @@ class RegistrationsController < Devise::RegistrationsController
end
def after_sign_up_path_for(user)
- Gitlab::AppLogger.info("User Created: username=#{user.username} email=#{user.email} ip=#{request.remote_ip} confirmed:#{user.confirmed?}")
+ Gitlab::AppLogger.info(user_created_message(confirmed: user.confirmed?))
user.confirmed? ? stored_location_for(user) || dashboard_projects_path : users_almost_there_path
end
def after_inactive_sign_up_path_for(resource)
- Gitlab::AppLogger.info("User Created: username=#{resource.username} email=#{resource.email} ip=#{request.remote_ip} confirmed:false")
+ Gitlab::AppLogger.info(user_created_message)
users_almost_there_path
end
private
+ def user_created_message(confirmed: false)
+ "User Created: username=#{resource.username} email=#{resource.email} ip=#{request.remote_ip} confirmed:#{confirmed}"
+ end
+
+ def ensure_correct_params!
+ # 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
+ end
+
def check_captcha
- return unless Feature.enabled?(:registrations_recaptcha, default_enabled: true)
+ ensure_correct_params!
+
+ return unless Feature.enabled?(:registrations_recaptcha, default_enabled: true) # reCAPTCHA on the UI will still display however
+ return unless show_recaptcha_sign_up?
return unless Gitlab::Recaptcha.load_configurations!
return if verify_recaptcha