Browse Source

minor change in the reset confirmation method to avoid errors if email in params is nil (#1676)

pull/1705/head
Arthur Campbell 2 years ago committed by GitHub
parent
commit
5b98a21907
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/controllers/auth/passwords_controller.rb
  2. 8
      spec/requests/auth/passwords_controller_spec.rb

2
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)

8
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

Loading…
Cancel
Save