From 15dafcb6ff403971bf863227317863699767f229 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Thu, 15 Feb 2024 10:27:04 +0200 Subject: [PATCH] downcase email when sign in --- app/controllers/sessions_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 96379fd9..b7ce7a8c 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -4,12 +4,14 @@ class SessionsController < Devise::SessionsController before_action :configure_permitted_parameters def create - if Docuseal.multitenant? && !User.exists?(email: sign_in_params[:email]) + email = sign_in_params[:email].to_s.downcase + + if Docuseal.multitenant? && !User.exists?(email:) return redirect_to new_registration_path(sign_up: true, user: sign_in_params.slice(:email)), notice: 'Create a new account' end - if User.exists?(email: sign_in_params[:email], otp_required_for_login: true) && sign_in_params[:otp_attempt].blank? + if User.exists?(email:, otp_required_for_login: true) && sign_in_params[:otp_attempt].blank? return render :otp, locals: { resource: User.new(sign_in_params) }, status: :unprocessable_entity end