From a08dd73621eaef979560a386ace1fdfab8e9f3b6 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 2 Nov 2023 12:51:35 +0000 Subject: [PATCH] Bug 21431: Add action parameter to set_password Added to the call in opac-password-recovery.pl. This allows differentiating between password change and password reset when viewing the logs. Test plan: Enable BorrowersLog. Do a password recovery on OPAC. Check with log viewer for 'RESET PASS' action. Signed-off-by: Marcel de Rooy Signed-off-by: Matt Blenkinsop Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- Koha/Patron.pm | 7 +++++-- opac/opac-password-recovery.pl | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 7571ca82fd..f5066ec5e9 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -902,10 +902,12 @@ sub is_going_to_expire { =head3 set_password - $patron->set_password({ password => $plain_text_password [, skip_validation => 1 ] }); + $patron->set_password({ password => $plain_text_password [, skip_validation => 1, action => NAME ] }); Set the patron's password. +Allows optional action parameter to change name of action logged (when enabled). Used for reset password. + =head4 Exceptions The passed string is validated against the current password enforcement policy. @@ -931,6 +933,7 @@ sub set_password { my ( $self, $args ) = @_; my $password = $args->{password}; + my $action = $args->{action} || "CHANGE PASS"; unless ( $args->{skip_validation} ) { my ( $is_valid, $error ) = Koha::AuthUtils::is_password_valid( $password, $self->category ); @@ -1019,7 +1022,7 @@ sub set_password { $self->login_attempts(0); $self->SUPER::store; - logaction( "MEMBERS", "CHANGE PASS", $self->borrowernumber, "" ) + logaction( "MEMBERS", $action, $self->borrowernumber, "" ) if C4::Context->preference("BorrowersLog"); return $self; diff --git a/opac/opac-password-recovery.pl b/opac/opac-password-recovery.pl index 5d56829846..0c0824c674 100755 --- a/opac/opac-password-recovery.pl +++ b/opac/opac-password-recovery.pl @@ -162,7 +162,7 @@ elsif ( $query->param('passwordReset') ) { $min_password_length = $borrower->category->effective_min_password_length; $require_strong_password = $borrower->category->effective_require_strong_password; try { - $borrower->set_password({ password => $password }); + $borrower->set_password({ password => $password, action => 'RESET PASS' }); CompletePasswordRecovery($uniqueKey); $template->param( -- 2.39.5