Replace attribute_changed? with new methods
This commit is contained in:
parent
e076910b74
commit
6e4c5bae29
1 changed files with 7 additions and 4 deletions
|
|
@ -473,14 +473,17 @@ class User < ApplicationRecord
|
||||||
def guard_unconfirmed_email
|
def guard_unconfirmed_email
|
||||||
self.unconfirmed_email = nil if unconfirmed_email.blank? || unconfirmed_email == email
|
self.unconfirmed_email = nil if unconfirmed_email.blank? || unconfirmed_email == email
|
||||||
|
|
||||||
if unconfirmed_email_changed?
|
return unless will_save_change_to_unconfirmed_email?
|
||||||
|
|
||||||
self.confirm_email_token = unconfirmed_email ? SecureRandom.hex(15) : nil
|
self.confirm_email_token = unconfirmed_email ? SecureRandom.hex(15) : nil
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# Whenever email is set, clear all unconfirmed emails which match
|
# Whenever email is set, clear all unconfirmed emails which match
|
||||||
def remove_invalid_unconfirmed_emails
|
def remove_invalid_unconfirmed_emails
|
||||||
User.where(unconfirmed_email: email).update_all(unconfirmed_email: nil, confirm_email_token: nil) if email_changed?
|
return unless saved_change_to_email?
|
||||||
|
# rubocop:disable Rails/SkipsModelValidations
|
||||||
|
User.where(unconfirmed_email: email).update_all(unconfirmed_email: nil, confirm_email_token: nil)
|
||||||
|
# rubocop:enable Rails/SkipsModelValidations
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generate public/private keys for User and associated Person
|
# Generate public/private keys for User and associated Person
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue