Bug 21191 - GDPR: Script to block inactive users (with no successful logins on a defined period)
Summary: GDPR: Script to block inactive users (with no successful logins on a defined ...
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Authentication (show other bugs)
Version: unspecified
Hardware: All All
: P2 enhancement (vote)
Assignee: Bugs List
QA Contact: Testopia
Depends on: 21336
  Show dependency treegraph
Reported: 2018-08-09 13:40 UTC by Vitor Fernandes
Modified: 2019-10-25 09:23 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Note You need to log in before you can comment on or make changes to this bug.
Description Vitor Fernandes 2018-08-09 13:40:46 UTC
Under the auspices of the recently issued European legislation regarding data privacy (GDPR), the Portuguese government has issued a series of mandatory requirements, as well as general recommendations, for software applications that are implemented under the umbrella of public bodies (RCM 41/2018).

Since Koha is mostly used by municipalities and universities in Portugal, some of these mandatory requirements need to be address by Koha implementers in Portugal.

We believe that this requirement is also useful for the community at large. Here’s a description of the requirement.

*** Requirement description ***

The application MUST record the time of a user last logged in. It should have a method to inactivate users that haven’t logged into the application for over X number of months (new setting).

*** Scope ***

Applies to implementations where user authentication is handled by Koha.
Comment 1 Magnus Enger 2018-08-13 07:46:07 UTC
What do you mean by "inactivate users"? 

I am no expert on GDPR, but from what I have seen, I would expect the requirement to be that patrons who have not been active for a given period of time should be deleted completely, also from the deletedborrowers table?
Comment 2 Joonas Kylmälä 2018-08-14 13:36:23 UTC
The last logon time is recorded in Koha if one enables it in preferences (TrackLastPatronActivity). It's also possible to delete patron information based on the last logon time with delete_patrons.pl cronjob.
Comment 3 Vitor Fernandes 2018-08-14 13:56:19 UTC
The legislation says that the users should be blocked (debarred) after some months of inactivity. Few months later they can be removed/deleted if they are still inactive.

TrackLastPatronActivity should be enough to create a script to block all inactive users.
Comment 4 Katrin Fischer 2018-08-14 14:04:42 UTC
Hi Vitor, for documentation purposes, could you add a link to a source here?
Comment 5 Vitor Fernandes 2018-08-14 14:24:28 UTC
The official document can be found in this link:

Comment 6 Marcel de Rooy 2018-09-12 11:27:08 UTC
Adding a see also to bug 21336 (processing unsubscribes).
There is a considerable overlap with this report.
Comment 7 Marcel de Rooy 2018-09-20 13:00:18 UTC
Bug 21336 adds a Patrons method lock (wrapper for Koha Patron lock).
So you only need to add a simple search.
Something like:

Koha::Patrons->search({ login_attempts => { '>=', pref_value }, lastseen => { '<', some_date }) -> lock;

Lock adds the option expire => 1 setting the expire date. Effectively disallowing holds, issues, etc.
And the option remove => 1 for removing holds and article requests.

So most work done already..