Bugzilla – Attachment 186525 Details for
Bug 40824
Add option to prevent re-use of passwords
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40824: Show category-specific password history count in error messages
Bug-40824-Show-category-specific-password-history-.patch (text/plain), 6.49 KB, created by
Jacob O'Mara
on 2025-09-17 09:48:04 UTC
(
hide
)
Description:
Bug 40824: Show category-specific password history count in error messages
Filename:
MIME Type:
Creator:
Jacob O'Mara
Created:
2025-09-17 09:48:04 UTC
Size:
6.49 KB
patch
obsolete
>From 52fb21b3e127e206d3265ae3fdc6cfdcfbcd88db Mon Sep 17 00:00:00 2001 >From: Jacob O'Mara <Jacob.omara@openfifth.co.uk> >Date: Thu, 14 Aug 2025 11:52:19 +0100 >Subject: [PATCH] Bug 40824: Show category-specific password history count in > error messages > >Update all password error message handlers to use the category-specific >effective_password_history_count method instead of the global system >preference: > >- members/member-password.pl >- members/memberentry.pl >- opac/opac-passwd.pl >- opac/opac-password-recovery.pl >- opac/opac-reset-password.pl >--- > members/member-password.pl | 3 +-- > members/memberentry.pl | 23 ++++++++++++----------- > opac/opac-passwd.pl | 5 +++-- > opac/opac-password-recovery.pl | 3 ++- > opac/opac-reset-password.pl | 5 +++-- > 5 files changed, 21 insertions(+), 18 deletions(-) > >diff --git a/members/member-password.pl b/members/member-password.pl >index 67406b2356b..be9d8bd5510 100755 >--- a/members/member-password.pl >+++ b/members/member-password.pl >@@ -82,9 +82,8 @@ if ( $op eq 'cud-update' && defined($newpassword) and not @errors ) { > } elsif ( $_->isa('Koha::Exceptions::Password::Plugin') ) { > push @errors, 'ERROR_from_plugin'; > } elsif ( $_->isa('Koha::Exceptions::Password::UsedBefore') ) { >- my $count = C4::Context->preference('PasswordHistoryCount') || 0; > push @errors, 'ERROR_password_used_before'; >- $template->param( 'password_history_count' => $count ); >+ $template->param( 'password_history_count' => $patron->category->effective_password_history_count ); > } else { > push( @errors, 'BADUSERID' ); > } >diff --git a/members/memberentry.pl b/members/memberentry.pl >index a567066e78e..6e74242701b 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -392,19 +392,20 @@ if ( $op eq 'cud-save' || $op eq 'cud-insert' ) { > push @errors, 'ERROR_password_too_weak' if $error eq 'too_weak'; > push @errors, 'ERROR_password_has_whitespaces' if $error eq 'has_whitespaces'; > } >- >+ > # Check password history >- if ($patron && $is_valid) { # Only check if other validations passed and we have a patron >- my $is_used = Koha::PatronPasswordHistories->has_used_password({ >- borrowernumber => $patron->borrowernumber, >- password => $password, >- current_password => $patron->password >- }); >- >+ if ( $patron && $is_valid ) { # Only check if other validations passed and we have a patron >+ my $is_used = Koha::PatronPasswordHistories->has_used_password( >+ { >+ borrowernumber => $patron->borrowernumber, >+ password => $password, >+ current_password => $patron->password >+ } >+ ); >+ > if ($is_used) { > push @errors, 'ERROR_password_used_before'; >- my $count = C4::Context->preference('PasswordHistoryCount') || 0; >- $template->param( password_history_count => $count ); >+ $template->param( password_history_count => $patron->category->effective_password_history_count ); > } > } > } >@@ -627,7 +628,7 @@ if ( ( !$nok ) and $nodouble and ( $op eq 'cud-insert' or $op eq 'cud-save' ) ) > } > } > >- # password validity has been checked above >+ # password validity has been checked above > my $password = $newdata{password}; > if ( $password and $password ne '****' and $success ) { > $patron->set_password( { password => $password } ); >diff --git a/opac/opac-passwd.pl b/opac/opac-passwd.pl >index 0b45a39d7b1..8b3f4a46eb5 100755 >--- a/opac/opac-passwd.pl >+++ b/opac/opac-passwd.pl >@@ -68,9 +68,10 @@ if ( $patron->category->effective_change_password ) { > if $_->isa('Koha::Exceptions::Password::TooWeak'); > $error = 'password_has_whitespaces' > if $_->isa('Koha::Exceptions::Password::WhitespaceCharacters'); >- if ($_->isa('Koha::Exceptions::Password::UsedBefore')) { >+ if ( $_->isa('Koha::Exceptions::Password::UsedBefore') ) { > $error = 'password_used_before'; >- $template->param( 'password_history_count' => C4::Context->preference('PasswordHistoryCount') ); >+ $template->param( >+ 'password_history_count' => $patron->category->effective_password_history_count ); > } > }; > } >diff --git a/opac/opac-password-recovery.pl b/opac/opac-password-recovery.pl >index e45f2d9015b..f27f7c5cfa0 100755 >--- a/opac/opac-password-recovery.pl >+++ b/opac/opac-password-recovery.pl >@@ -179,8 +179,9 @@ if ( $op eq 'cud-sendEmail' || $op eq 'cud-resendEmail' ) { > $error = 'password_has_whitespaces'; > } elsif ( $_->isa('Koha::Exceptions::Password::TooWeak') ) { > $error = 'password_too_weak'; >- } elsif ($_->isa('Koha::Exceptions::Password::UsedBefore')) { >+ } elsif ( $_->isa('Koha::Exceptions::Password::UsedBefore') ) { > $error = 'password_used_before'; >+ $template->param( password_history_count => $borrower->category->effective_password_history_count ); > } > }; > } >diff --git a/opac/opac-reset-password.pl b/opac/opac-reset-password.pl >index 2ca8c6f8956..8b0ae4e73c8 100755 >--- a/opac/opac-reset-password.pl >+++ b/opac/opac-reset-password.pl >@@ -71,9 +71,10 @@ if ( $op eq 'cud-update' ) { > if $_->isa('Koha::Exceptions::Password::TooWeak'); > $error = 'password_has_whitespaces' > if $_->isa('Koha::Exceptions::Password::WhitespaceCharacters'); >- if ($_->isa('Koha::Exceptions::Password::UsedBefore')) { >+ if ( $_->isa('Koha::Exceptions::Password::UsedBefore') ) { > $template->param( password_used_before => 1 ); >- $template->param( password_history_count => C4::Context->preference('PasswordHistoryCount') ); >+ $template->param( >+ password_history_count => $patron->category->effective_password_history_count ); > } > $template->param( 'error' => $error ); > }; >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40824
:
186511
|
186512
|
186513
|
186514
|
186515
|
186516
|
186517
|
186518
|
186519
|
186520
|
186521
|
186522
|
186523
|
186524
| 186525 |
186526
|
186527