Skip to content

Remove user accounts created by bots

Recently a lot of user accounts seem to be created by bots. With #712 (closed) this should be stopped for the moment.

To remove these accounts, I suggest adding a daily task, which removes user accounts that match all of the following criteria:

  • account is older than 30 days
  • never logged in or time span between account creation and last login is less than 5 seconds
  • email address is not verified
  • no memberships, no subscriptions
  • no content (versions)
  • no comments or messages
  • no images, no poll votes

The following fragment and the account deletion code can help with implementation:

for user in User.objects.filter(emailaddress__verified=False):
    if not user.last_login or ((user.last_login - user.date_joined) < timedelta(seconds=5)):
        // check memberships, content etc.
Edited by Robert