-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify Spree::User
and Spree::Order
email validation
#3427
Comments
A bit more context on why this can be insidious, again from Solidus sandbox: u = Spree::User.create email: '[email protected]', password: 'password', password_confirmation: 'password'
o = u.orders.create
o.persisted?
# => true
o.valid?
# => false
o.errors[:email]
=> ["is invalid"] The order is valid before being persisted, as the email field is blank. After the order is persisted, it becomes invalid as the email field, copied from the user, is not valid according to the validator. |
Hi there, I took a look at and Then, replacing core/lib/spree/core/validators/email.rb - unless EMAIL_REGEXP.match? value
+ email_regexp = defined?(Devise) && defined?(Devise::email_regexp) ? Devise::email_regexp : EMAIL_REGEXP
+ unless email_regexp.match? value WDYT? |
For what it's worth, the email regexp used in orders can now be configured: solidus/core/lib/spree/app_configuration.rb Line 156 in 38ef164
|
(not sure if this is more a bug or a new feature... I'm going for the latter as I think the solution will end up being a new feature 😄 )
At the moment we have a custom validator for the email in
Spree::Order
. This validator has different logic than the one used insolidus_auth_devise
, so there may be instances when the user is valid, but the order is not. This creates confusion and can affect shop sales negatively when the issue goes unnoticed.One possible course of action may be to use the same validator from
solidus_auth_devise
, which happens to be the one used bydevise
, as it's more used (if not respectful of standards) than ours... but only when the application is usingsolidus_auth_devise
as well. More in general, if a user validator for email exists, the order should use that one instead of the one provided by Solidus.The text was updated successfully, but these errors were encountered: