Identify invalid/unverified/unused accounts

First off, thanks for all your work on this, we’re very happy using zammad! \o/

We’re new to zammad and we’d like to know how to delete user accounts that have not verified their email addresses. The service we provide is publicly open and it’s common that users try (or manage) to register an account without any intention to create a ticket and ask for assistance (sometimes even with non-existing email addresses). The problem with this is that these accounts will just take up space over time so we would like to perform regular clean ups.

For the users that do verify their account and log in we have found we can set a scheduler to delete them (role: xxx, last login: xxx, existing tickets: no).

We cannot find how to identify accounts that do not verify their email address. If there is no built in way to do this then the workaround we have thought of is to set a scheduler to delete any user accounts that have no tickets. Unfortunately we anticipate that this will create problems when the scheduler runs at the time between someone creating an account and submitting their ticket.

I’ve read the docs and looked over the community, apologies in advance if I’m missing something very obvious. It would be great help to be pointed in the right direction or get some feedback on whether there’s a better way to do this.

My questions are:

  • Is there a way to know when an account hasn’t verified their email address?

  • Is there a way to know if an account hasn’t logged in?

1 Like

Hi Olil,

what you’re trying to accomplish would be possible via the Rails-console. However, if you don’t know exactly what you’re doing, you can (and most likely will) shoot yourself in the foot and cause irreversible data-loss in the process.

Please understand therefore that I won’t give you a step-by-step instruction. I can only point you in the vague direction to find what you need:

On the Rails-console, you can find a specific user by (e.g.) the user’s email address:

User.find_by(email: 'user@example.org')

The Output will then be the complete record of that user. Four attributes are relevant for your use case here: “verified”, “active”, “source”, and “last_login”

For example, a user who signed up via the web-app, is active but unverified and has never logged in would show up with these values:

verified: false,
active: true,

[...]

source: "signup",

[...]

last_login: nil,

How to delete records from Zammad via the console, you can find in the DANGER ZONE of our official documentation. As the name implies (and I know I said this before, but it can’t be emphasized enough), commands here are dangerous, and you absolutely need to know what you’re doing before attempting anything in this direction.

If you are familiar with working on the Rails-console, you’ll have no trouble taking it from here. For example by writing a script that identifies all users that apply to any given criteria and then perform any given action on them.

You’re on your own from here on out.

1 Like

Hey Tarek!

Thank you for the guidance - and the warnings! I’m personally not well versed in rails but a member of our team is so I will pass it on and I’m sure we’ll make something that works for us.