プロジェクト

全般

プロフィール

Vote #79900

完了

Add an rake task to prune registered users after a certain number of days

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Accounts / authentication_7
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
7
version_id:
155
issue_org_id:
30998
author_id:
3939
assigned_to_id:
332
comments:
11
status_id:
5
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

Hello,

Unfortunately I'm not enough skilled in ruby to propose a patch.

Like many other people, I'm affected by spammers that half-register themselves but do not complete inscriptions due their fake emails. So I constantly have a pile of half-registered users that pollute my database.

It could be nice if there was an option to automatically delete accounts that were not successfully registered after a given amount of time (example, 1 day by default or something like that).

What do you think?


journals

For those who are interested, I usually process this easily by:

<pre>
delete from users where status = 2;
</pre>

Not sure if it's really safe while redmine is running though.
--------------------------------------------------------------------------------
How about adding a rake task @redmine:users:prune@ to remove users who have not completed their registration?

Redmine already has a similarly named rake task @redmine:attachments:prune@ (source:tags/4.2.0/lib/tasks/redmine.rake#L20). The rake task deletes files that have been uploaded but not attached to an issue or wiki page.

--------------------------------------------------------------------------------
Go MAEDA wrote:
> How about adding a rake task @redmine:users:prune@ to remove users who have not completed their registration?

+1
I created a rake task @redmine:users:prune@.

<pre><code class="diff">
diff --git a/app/models/user.rb b/app/models/user.rb
index a3d2449d2..af65d5aaa 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -887,6 +887,10 @@ class User < Principal
project_ids.map(&:to_i)
end

+ def self.prune(age=1.day)
+ User.where("created_on < ? AND status = ?", Time.now - age, STATUS_REGISTERED).destroy_all
+ end
+
protected

def validate_password_length
diff --git a/lib/tasks/redmine.rake b/lib/tasks/redmine.rake
index 2bebaf18c..8cdf6f80f 100644
--- a/lib/tasks/redmine.rake
+++ b/lib/tasks/redmine.rake
@@ -40,6 +40,13 @@ namespace :redmine do
end
end

+ namespace :users do
+ desc 'Remove users who could not be activated after one day.'
+ task :prune => :environment do
+ User.prune
+ end
+ end
+
namespace :watchers do
desc 'Removes watchers from what they can no longer view.'
task :prune => :environment do
</code></pre>

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Thank you for the patch.

I have changed the patch to remove users registered more than 7 days ago. I think one day is too short.

Suppose that you set "Self-registration" to "manual account activation" and run the rake task every day. When the admin receives a notification that a user has registered, the admin must activate the user within one day or the user will be deleted. All users who register after Friday afternoon may be deleted by Monday morning.
--------------------------------------------------------------------------------
Updated the patch for the trunk r21318. Setting the target version to 5.0.0.
--------------------------------------------------------------------------------
The rake task should accept the number of days as parameter in order to make this configurable. Also, the default value should be at least 7 days or even 30 days. One day is too less.
--------------------------------------------------------------------------------
Go Maeda, what do you think about the following implementation?
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Marius BALTEANU wrote:
> Go Maeda, what do you think about the following implementation?

Looks nice, thank you!
--------------------------------------------------------------------------------
Committed the patch. Thank you.
--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリAccounts / authentication_7 にセット
  • 対象バージョン5.0.0_155 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0