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 <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Marcel de Rooy 2023-11-02 12:51:35 +00:00 committed by Tomas Cohen Arazi
parent a3c6207627
commit a08dd73621
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
2 changed files with 6 additions and 3 deletions

View File

@ -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;

View File

@ -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(