@@ -, +, @@ - makes the previous link invalid - reset the timestamp to allow for two more days. --- C4/Members.pm | 11 ++++++++--- opac/opac-password-recovery.pl | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) --- a/C4/Members.pm +++ a/C4/Members.pm @@ -2268,6 +2268,7 @@ sub SendPasswordRecoveryEmail { my $borrowernumber = shift; my $email = shift; my $query = shift; + my $update = shift; my $dbh = C4::Context->dbh; my $username = GetMemberDetails($borrowernumber)->{userid}; @@ -2278,9 +2279,13 @@ sub SendPasswordRecoveryEmail { #insert into database my $expirydate = DateTime->now(time_zone => C4::Context->tz())->add( days => 2 ); - my $sth = $dbh->prepare( 'INSERT INTO borrower_password_recovery VALUES (?, ?, ?)'); - $sth->execute($borrowernumber, $uuid_str, $expirydate->ymd()); - + if($update){ + my $sth = $dbh->prepare( 'UPDATE borrower_password_recovery set uuid=?, valid_until=? where borrowernumber=?'); + $sth->execute($uuid_str, $expirydate->datetime(), $borrowernumber); + } else { + my $sth = $dbh->prepare( 'INSERT INTO borrower_password_recovery VALUES (?, ?, ?)'); + $sth->execute($borrowernumber, $uuid_str, $expirydate->ymd()); + } my $userEmail = ( $email ) ? $email : GetFirstValidEmailAddress($borrowernumber); #define to/from emails my $kohaEmail = C4::Context->preference( 'KohaAdminEmailAddress' ); --- a/opac/opac-password-recovery.pl +++ a/opac/opac-password-recovery.pl @@ -87,7 +87,7 @@ if ( $query->param('sendEmail') || $query->param('resendEmail') ) { email => HTML::Entities::encode($email), ); } - elsif ( SendPasswordRecoveryEmail( $borrower_number, $email, $query ) ) {#generate uuid and send recovery email + elsif ( SendPasswordRecoveryEmail( $borrower_number, $email, $query, $query->param('resendEmail') ) ) {#generate uuid and send recovery email $template->param( mail_sent => 1, email => $email --