]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/user.rb
Remove unused .current from primary nav
[rails.git] / app / models / user.rb
index 3d74b3933ec2c7eaabdf49585ff8ba0206b8fa0d..1942a25cc237a784394b91f9ba64c844f36e3309 100644 (file)
@@ -115,6 +115,7 @@ class User < ApplicationRecord
 
   alias_attribute :created_at, :creation_time
 
 
   alias_attribute :created_at, :creation_time
 
+  after_initialize :encrypt_password
   before_save :encrypt_password
   before_save :update_tile
   after_save :spam_check
   before_save :encrypt_password
   before_save :update_tile
   after_save :spam_check
@@ -418,6 +419,18 @@ class User < ApplicationRecord
     end
   end
 
     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
   private
 
   def encrypt_password