From 0f4de0d18da603fa52c2928b767839094dc681bb Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 4 Sep 2018 11:32:31 -0400 Subject: [PATCH] Bug 21314: Koha enforces three (3) character password length even if RequireStrongPassword is disabled Bug 18298 added the option to enforce password complexity *if* the new system preference RequireStrongPassword is enabled. However, it appears that the code defining the minimum number of characters was not put under control of this preference and thus Koha enforces a minimum password length of 3 even if RequireStrongPassword is disabled. Test Plan: 1) Set minPasswordLength to 2 2) Disable RequireStrongPassword 3) Attempt to change a password to a two character password 4) Note Koha tells you the minimum length is 3 characters 5) Apply this patch 6) Restart memached/plack, Reload the page 7) You should now be able to set the password to a 2 character string --- C4/Auth.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 70d41c7854..6c2ada6e18 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -416,8 +416,11 @@ sub get_template_and_user { my $https = $in->{query}->https(); my $using_https = ( defined $https and $https ne 'OFF' ) ? 1 : 0; - my $minPasswordLength = C4::Context->preference('minPasswordLength'); - $minPasswordLength = 3 if not $minPasswordLength or $minPasswordLength < 3; + my $minPasswordLength = C4::Context->preference('minPasswordLength') || 0; + if ( C4::Context->preference('RequireStrongPassword') ) { + $minPasswordLength = 3 if $minPasswordLength < 3; + } + $template->param( "BiblioDefaultView" . C4::Context->preference("BiblioDefaultView") => 1, EnhancedMessagingPreferences => C4::Context->preference('EnhancedMessagingPreferences'), -- 2.11.0