From efb67faa059eb4ac2b5ae3be94f22fb2012d6aa9 Mon Sep 17 00:00:00 2001 From: VINAY MITTAL Date: Sat, 30 Jul 2016 13:01:44 +0530 Subject: [PATCH] optimize callback and change login field on email change --- app/models/spree/user.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/spree/user.rb b/app/models/spree/user.rb index 08bffc0a7..decbd6559 100644 --- a/app/models/spree/user.rb +++ b/app/models/spree/user.rb @@ -11,7 +11,7 @@ class User < Spree::Base acts_as_paranoid after_destroy :scramble_email_and_password - before_validation :set_login + before_validation :set_login, if: :email_changed? users_table_name = User.table_name roles_table_name = Role.table_name @@ -35,7 +35,7 @@ def password_required? def set_login # for now force login to be same as email, eventually we will make this configurable, etc. - self.login ||= self.email if self.email + self.login = self.email end def scramble_email_and_password