@@ -, +, @@ expired reset-entry exists. --- Koha/Patron/Password/Recovery.pm | 15 +++------------ members/notices.pl | 5 +---- opac/opac-password-recovery.pl | 2 +- t/db_dependent/Passwordrecovery.t | 4 ++-- 4 files changed, 7 insertions(+), 19 deletions(-) --- a/Koha/Patron/Password/Recovery.pm +++ a/Koha/Patron/Password/Recovery.pm @@ -106,7 +106,6 @@ sub GetValidLinkInfo { sub SendPasswordRecoveryEmail { my $borrower = shift; # Koha::Patron my $userEmail = shift; #to_address (the one specified in the request) - my $update = shift; my $staff = shift // 0; my $schema = Koha::Database->new->schema; @@ -121,22 +120,14 @@ sub SendPasswordRecoveryEmail { my $days = $staff ? STAFF : PATRON; my $expirydate = dt_from_string()->add( days => $days ); - if ($update) { - my $rs = - $schema->resultset('BorrowerPasswordRecovery') - ->search( { borrowernumber => $borrower->borrowernumber, } ); - $rs->update( - { uuid => $uuid_str, valid_until => $expirydate->datetime() } ); - } - else { - my $rs = $schema->resultset('BorrowerPasswordRecovery')->create( + my $rs = $schema->resultset('BorrowerPasswordRecovery')->update_or_create( { borrowernumber => $borrower->borrowernumber, uuid => $uuid_str, valid_until => $expirydate->datetime() - } + }, + { key => 'primary' } ); - } # create link my $opacbase = C4::Context->preference('OPACBaseURL') || ''; --- a/members/notices.pl +++ a/members/notices.pl @@ -100,11 +100,8 @@ if ( $op eq 'send_password_reset' ) { if ($emailaddr) { - # check if there's already a recovery in process - my $update = ValidateBorrowernumber( $patron->borrowernumber ); - # send staff initiated password recovery - SendPasswordRecoveryEmail( $patron, $emailaddr, $update, 1 ); + SendPasswordRecoveryEmail( $patron, $emailaddr, 1 ); } # redirect to self to avoid form submission on refresh --- a/opac/opac-password-recovery.pl +++ a/opac/opac-password-recovery.pl @@ -133,7 +133,7 @@ if ( $query->param('sendEmail') || $query->param('resendEmail') ) { username => $username ); } - elsif ( SendPasswordRecoveryEmail( $borrower, $email, scalar $query->param('resendEmail') ) ) { # generate uuid and send recovery email + elsif ( SendPasswordRecoveryEmail( $borrower, $email ) ) { # generate uuid and send recovery email $template->param( mail_sent => 1, email => $email --- a/t/db_dependent/Passwordrecovery.t +++ a/t/db_dependent/Passwordrecovery.t @@ -200,7 +200,7 @@ ok( Koha::Patron::Password::Recovery::DeleteExpiredPasswordRecovery($borrowernum my $borrower = Koha::Patrons->search( { userid => $userid1 } )->next; my $success; warning_is { - $success = Koha::Patron::Password::Recovery::SendPasswordRecoveryEmail($borrower, $email1, 0); } + $success = Koha::Patron::Password::Recovery::SendPasswordRecoveryEmail($borrower, $email1 ); } "Fake sendmail", '[SendPasswordRecoveryEmail] expecting fake sendmail'; ok( $success == 1, '[SendPasswordRecoveryEmail] Returns 1 on success'); @@ -212,7 +212,7 @@ my $bpr = $schema->resultset('BorrowerPasswordRecovery')->search( { borrowernumb my $tempuuid1 = $bpr->next->uuid; warning_is { - Koha::Patron::Password::Recovery::SendPasswordRecoveryEmail($borrower, $email1, 1); } + Koha::Patron::Password::Recovery::SendPasswordRecoveryEmail($borrower, $email1 ); } "Fake sendmail", '[SendPasswordRecoveryEmail] expecting fake sendmail'; --