From 6056c593013e737e7d5c43480d5e469527e38c38 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 3 Aug 2023 10:22:00 +1000 Subject: [PATCH 1/2] Skip online domain validation of dev user email We improved the email address validation to check the domain for existing DNS entries. But our default user has the example.com domain which is not resolved by my internet service provider. I couldn't find a better way to deactivate this one check than overriding the method in the validator. The code does not affect other parts of the app unless you run multiple rake tasks in the same command line with the database setup. --- db/default/users.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/db/default/users.rb b/db/default/users.rb index 192fee97f2..8e4b16cc76 100644 --- a/db/default/users.rb +++ b/db/default/users.rb @@ -58,6 +58,10 @@ def create_admin_user admin = Spree::User.new(attributes) admin.skip_confirmation! admin.skip_confirmation_notification! + + # The default domain example.com is not resolved by all nameservers. + ValidEmail2::Address.define_method(:valid_mx?) { true } + if admin.save role = Spree::Role.find_or_create_by(name: 'admin') admin.spree_roles << role From c8511ecd0db1af8ff27736726d8b91c05d560f9c Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 3 Aug 2023 10:26:59 +1000 Subject: [PATCH 2/2] Remove superfluous line The `<<` operation saves the association already. --- db/default/users.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/db/default/users.rb b/db/default/users.rb index 8e4b16cc76..96c8350fe4 100644 --- a/db/default/users.rb +++ b/db/default/users.rb @@ -65,7 +65,6 @@ def create_admin_user if admin.save role = Spree::Role.find_or_create_by(name: 'admin') admin.spree_roles << role - admin.save say "New admin user persisted!" else say "There was some problems with persisting new admin user:"