From e6899b0139cea557d5e3f9173d515a909303571c Mon Sep 17 00:00:00 2001 From: Magnus Enger Date: Tue, 29 Dec 2020 12:39:19 +0100 Subject: [PATCH] Bug 27311 - Don't pass borrowernumber to check_password Bug 22706 added the check_password plugin hook, taking both a borrowernumber and the raw password as arguments. The hook is called in two places in Koha::Patron, but because of how the code that calls the hook is placed, passing borrowernumber to the plugin inside "sub store" never worked. This patch removes the passing of the borrowernumber from both calls. A tiny plugin that uses the check_password hooks can ve found here: https://github.com/Libriotech/koha-plugin-pin To test: - Enable plugins - Optionally install the PIN plugin - Add and edit users in all possible ways, including -- Setting a password for a new user -- Changing a password in the staff client -- Changing a password in the OPAC -- Creating a disabled user account Sign off, if all this works as expected. --- Koha/Patron.pm | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 64e8fac486..8d55b41fd1 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -243,7 +243,6 @@ sub store { my $ret = $plugin->check_password( { password => $self->password, - borrowernumber => $self->borrowernumber } ); if ( $ret->{'error'} == 1 ) { @@ -830,18 +829,12 @@ sub set_password { method => 'check_password', }); foreach my $plugin ( @plugins ) { - # This plugin hook will also be used by a plugin for the Norwegian national - # patron database. This is why we need to pass both the password and the - # borrowernumber to the plugin. my $ret = $plugin->check_password( { password => $password, - borrowernumber => $self->borrowernumber } ); - # This plugin hook will also be used by a plugin for the Norwegian national - # patron database. This is why we need to call the actual plugins and then - # check skip_validation afterwards. + # Only throw an exception if skip_validation is not in effect if ( $ret->{'error'} == 1 && !$args->{skip_validation} ) { Koha::Exceptions::Password::Plugin->throw(); } -- 2.17.1