Bug 37104: (Follow up) Restructure checkpw code

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Sam Lau 2024-06-17 19:25:34 +00:00 committed by Katrin Fischer
parent 0f2a5bf987
commit 99b2fab569
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -1418,8 +1418,8 @@ sub checkauth {
my $auth_template_name = ( $type eq 'opac' ) ? 'opac-auth.tt' : 'auth.tt';
my $template = C4::Templates::gettemplate( $auth_template_name, $type, $query );
my $borrowernumber = $patron and $patron->borrowernumber;
my $anonymous_patron = C4::Context->preference('AnonymousPatron');
my $borrowernumber = $patron and $patron->borrowernumber;
my $anonymous_patron = C4::Context->preference('AnonymousPatron');
my $is_anonymous_patron = $patron && ( $patron->borrowernumber eq $anonymous_patron );
$template->param(
@ -2062,10 +2062,9 @@ sub checkpw {
@return = ();
} elsif ($passwd_ok) {
$patron->update( { login_attempts => 0 } );
if ( $patron->password_expired ) {
@return = ( -2, $patron );
}
if ( $patron->borrowernumber eq $anonymous_patron ) {
@return = ( -3, $patron );
} elsif ( $patron->password_expired ) {
@return = ( -2, $patron );
}
} else {