Validate user email syntax on change

We probably have invalid entries in the database and we don't want these
records to suddenly become invalid. People would not be able to log in.
This commit is contained in:
Maikel Linke
2023-05-15 16:01:15 +10:00
committed by Konrad
parent 101b9025b4
commit ffc45f77cf
2 changed files with 2 additions and 1 deletions

View File

@@ -48,6 +48,7 @@ module Spree
after_create :associate_customers, :associate_orders
validates :email, 'valid_email_2/email': true, if: :email_changed?
validate :limit_owned_enterprises
validates :uid, uniqueness: true, if: lambda { uid.present? }
validates_email :uid, if: lambda { uid.present? }

View File

@@ -92,7 +92,7 @@ describe Spree::User do
expect(user.errors.messages[:email]).to include "is invalid"
end
pending "detects backslashes at the end" do
it "detects backslashes at the end" do
user.email = "example@gmail.com\\\\"
expect(user).to_not be_valid
end