]> 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)
committerLucas Gass <lucas@bywatersolutions.com>
Mon, 5 Dec 2022 22:38:12 +0000 (22:38 +0000)
commit7a33e61858e6f463c5e3ef32eb07753df0db3afa
tree4f2257eb808112b9bde565c507507ffee3a4b40c
parent1c17ce33354a31b182f1b1393dbfe2693bc33065
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>
(cherry picked from commit 043017af13a80ad432c597699f35e50260ed21ca)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Koha/Patron/Password/Recovery.pm
members/notices.pl
opac/opac-password-recovery.pl
t/db_dependent/Passwordrecovery.t