From 8a2f34d8154b57421aabf2de075785acede9fe8a Mon Sep 17 00:00:00 2001 From: Developer <> Date: Thu, 11 Feb 2021 00:33:28 -0500 Subject: [PATCH] Added check in RegistrationsController to ensure email and password don't match MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Added: - check in RegistrationsController to ensure email and password don't match. If so, return back to registration form with alert --- app/controllers/auth/registrations_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/auth/registrations_controller.rb b/app/controllers/auth/registrations_controller.rb index 1f3a1374..4fc0a708 100644 --- a/app/controllers/auth/registrations_controller.rb +++ b/app/controllers/auth/registrations_controller.rb @@ -9,6 +9,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController before_action :set_instance_presenter, only: [:new, :create, :update] before_action :set_body_classes, only: [:new, :create, :edit, :update] before_action :set_cache_headers, only: [:edit, :update] + prepend_before_action :check_if_password_email_identical, only: [:create] prepend_before_action :check_captcha, only: [:create] def new @@ -62,6 +63,15 @@ class Auth::RegistrationsController < Devise::RegistrationsController private + def check_if_password_email_identical + if params[:user][:email] == params[:user][:password] + flash[:alert] = "Your email cannot be your password. Please enter a new password." + respond_with_navigational(resource) { + redirect_to new_user_registration_path + } + end + end + def check_captcha unless passed_challenge?(params["gab-captcha-st"], params[:user]) self.resource = resource_class.new configure_sign_up_params