]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
cron: fix deletion of unactivated accounts
authorDaniel Axtens <dja@axtens.net>
Tue, 11 Jul 2017 06:30:48 +0000 (16:30 +1000)
committerStephen Finucane <stephen@that.guru>
Wed, 12 Jul 2017 09:33:38 +0000 (10:33 +0100)
There is a test in expire_notifications() that tries to check if
the user's last login matches the date joined. (I think the login
date is not set until a post-activation login.) This does not work:
on patchwork.ozlabs.org there are 10k users that have never been
deleted.

Drop the date test: it should be sufficient that a user is not
active and their confirmation is not pending.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
patchwork/notifications.py

index 16152ef9d19530d11aa1226354336a75ecf789b7..840d2cf915dd3fe8e25bfe051e22e13a947e7439 100644 (file)
@@ -25,7 +25,8 @@ from django.conf import settings
 from django.contrib.auth.models import User
 from django.contrib.sites.models import Site
 from django.core.mail import EmailMessage
-from django.db.models import Count, Q, F
+from django.db.models import Count
+from django.db.models import Q
 
 from patchwork.compat import render_to_string
 from patchwork.models import EmailConfirmation
@@ -109,9 +110,7 @@ def expire_notifications():
 
     # remove inactive users with no pending confirmation
     pending_confs = EmailConfirmation.objects.values('user')
-    users = User.objects.filter(is_active=False,
-                                last_login=F('date_joined')).exclude(
-                                    id__in=pending_confs)
+    users = User.objects.filter(is_active=False).exclude(id__in=pending_confs)
 
     # delete users
     users.delete()