]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/user.rb
Refactor app/views/messages templates
[rails.git] / app / models / user.rb
index 7571dd9dc5c8011f4615ebf970b6f0daa377adc9..1942a25cc237a784394b91f9ba64c844f36e3309 100644 (file)
@@ -419,6 +419,18 @@ class User < ApplicationRecord
     end
   end
 
+  def deletion_allowed_at
+    unless Settings.user_account_deletion_delay.nil?
+      last_changeset = changesets.reorder(:closed_at => :desc).first
+      return last_changeset.closed_at.utc + Settings.user_account_deletion_delay.hours if last_changeset
+    end
+    creation_time.utc
+  end
+
+  def deletion_allowed?
+    deletion_allowed_at <= Time.now.utc
+  end
+
   private
 
   def encrypt_password