]> git.koha-community.org Git - koha.git/commit
Bug 31739: Password recovery from staff fails if previous expired reset-entry exists.
authorBjörn Nylén <bjorn.nylen@ub.lu.se>
Wed, 12 Oct 2022 11:54:11 +0000 (11:54 +0000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 24 Oct 2022 17:12:16 +0000 (14:12 -0300)
commit043017af13a80ad432c597699f35e50260ed21ca
treea5fac3e0b39f948c83496f9d70c7ab765ff1422f
parent68212460a1f43f0eac25efa2b922ab4cdfa292ca
Bug 31739: Password recovery from staff fails if previous expired reset-entry exists.

SendPasswordRecoveryEmail relies on the calling script to tell if there is an
existing valid recovery already. If there's an expired recovery-entry the
members/notices.pl script will try to create a new entry resulting in a duplicate
key error.

This patch fixes the bug by removing the need for the calling script to do the check as
since SendPasswordRecoveryEmail does the same thing anyway.
SendPasswordRecoveryEmail will now use DBIx ->update_or_create instead of looking at
the $update param to determine if it should update an existing entry or create a new.

The update param is removed from all calling scripts and test are updated.

To test:
1. Generate a password recovery mail for a patron
2. Let it expire.
3. Generate a new password recovery from staff to the same patron - Fail!
4: Apply patch
5. Generate a new password recovery from staff to the same patron - Success!
6. Opac password recovery flow should also work.
7. Tests pass.

Sponsored-by: Lund University Library
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Koha/Patron/Password/Recovery.pm
members/notices.pl
opac/opac-password-recovery.pl
t/db_dependent/Passwordrecovery.t