From 5b98a2190709cf7c0bd3766184e50b0352b9dbe9 Mon Sep 17 00:00:00 2001 From: Arthur Campbell <51094020+arfacamble@users.noreply.github.com> Date: Thu, 15 Jun 2023 15:01:24 +0100 Subject: [PATCH] minor change in the reset confirmation method to avoid errors if email in params is nil (#1676) --- app/controllers/auth/passwords_controller.rb | 2 +- spec/requests/auth/passwords_controller_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/auth/passwords_controller.rb b/app/controllers/auth/passwords_controller.rb index c76ebaf6a..a990325f9 100644 --- a/app/controllers/auth/passwords_controller.rb +++ b/app/controllers/auth/passwords_controller.rb @@ -4,7 +4,7 @@ class Auth::PasswordsController < Devise::PasswordsController def reset_confirmation self.resource = resource_class.new @email = params["email"] - if @email.empty? + if @email.blank? resource.errors.add :email, I18n.t("validations.email.blank") render "devise/passwords/new", status: :unprocessable_entity elsif !email_valid?(@email) diff --git a/spec/requests/auth/passwords_controller_spec.rb b/spec/requests/auth/passwords_controller_spec.rb index 70357062e..29a032395 100644 --- a/spec/requests/auth/passwords_controller_spec.rb +++ b/spec/requests/auth/passwords_controller_spec.rb @@ -145,4 +145,12 @@ RSpec.describe Auth::PasswordsController, type: :request do end end end + + context "when a password is reset" do + let(:email) { nil } + + it "does not error if the email is nil or not in the params" do + expect { get account_password_reset_confirmation_path(email:) }.not_to raise_error + end + end end