diff options
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 00e2af458..7f47ecc3f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -119,6 +119,7 @@ class User < ApplicationRecord before_validation :sanitize_languages before_create :set_approved + before_save :set_last_fanged_at # This avoids a deprecation warning from Rails 5.1 # It seems possible that a future release of devise-two-factor will @@ -532,6 +533,11 @@ class User < ApplicationRecord self.approved = open_registrations? || valid_invitation? || external? end + def set_last_fanged_at + return unless defanged_changed? && !last_fanged_at_changed? + self.last_fanged_at = (defanged? ? nil : Time.now.utc) + end + def open_registrations? Setting.registrations_mode == 'open' end |