FEATURE: set purge_unactivated_users_grace_period_days to 0 to disable purging unactivated users

This commit is contained in:
Neil Lalonde 2017-08-25 15:20:06 -04:00
parent d911d3ff6e
commit 398604ac71
3 changed files with 12 additions and 1 deletions

View File

@ -1061,6 +1061,8 @@ class User < ActiveRecord::Base
# Delete unactivated accounts (without verified email) that are over a week old
def self.purge_unactivated
return [] if SiteSetting.purge_unactivated_users_grace_period_days <= 0
to_destroy = User.where(active: false)
.joins('INNER JOIN user_stats AS us ON us.user_id = users.id')
.where("created_at < ?", SiteSetting.purge_unactivated_users_grace_period_days.days.ago)

View File

@ -1192,7 +1192,7 @@ en:
clean_up_uploads: "Remove orphan unreferenced uploads to prevent illegal hosting. WARNING: you may want to back up of your /uploads directory before enabling this setting."
clean_orphan_uploads_grace_period_hours: "Grace period (in hours) before an orphan upload is removed."
purge_deleted_uploads_grace_period_days: "Grace period (in days) before a deleted upload is erased."
purge_unactivated_users_grace_period_days: "Grace period (in days) before a user who has not activated their account is deleted."
purge_unactivated_users_grace_period_days: "Grace period (in days) before a user who has not activated their account is deleted. Set to 0 to never purge unactivated users."
enable_s3_uploads: "Place uploads on Amazon S3 storage. IMPORTANT: requires valid S3 credentials (both access key id & secret access key)."
s3_use_iam_profile: 'Use AWS EC2 IAM role to retrieve keys. NOTE: enabling will override "s3 access key id" and "s3 secret access key" settings.'
s3_upload_bucket: "The Amazon S3 bucket name that files will be uploaded into. WARNING: must be lowercase, no periods, no underscores."

View File

@ -1183,6 +1183,15 @@ describe User do
expect(all_users.include?(inactive)).to eq(true)
expect(all_users.include?(inactive_old)).to eq(false)
end
it "does nothing if purge_unactivated_users_grace_period_days is 0" do
SiteSetting.purge_unactivated_users_grace_period_days = 0
User.purge_unactivated
all_users = User.all
expect(all_users.include?(user)).to eq(true)
expect(all_users.include?(inactive)).to eq(true)
expect(all_users.include?(inactive_old)).to eq(true)
end
end
describe "hash_passwords" do