Added check in RegistrationsController to ensure email and password don't match

• Added:
- check in RegistrationsController to ensure email and password don't match. If so, return back to registration form with alert
This commit is contained in:
Developer 2021-02-11 00:33:28 -05:00
parent 39a3d44bdd
commit 8a2f34d815
1 changed files with 10 additions and 0 deletions

View File

@ -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