From 40da71fd8103316ae944b8eec0a3b79dd8110c60 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 5 Sep 2018 06:46:18 -0400 Subject: [PATCH] Bug 21314: Fix duplicate code in Koha::AuthUtils::is_password_valid --- Koha/AuthUtils.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Koha/AuthUtils.pm b/Koha/AuthUtils.pm index a42705fd9b..3ab39907f1 100644 --- a/Koha/AuthUtils.pm +++ b/Koha/AuthUtils.pm @@ -148,8 +148,12 @@ otherwise return $is_valid == 0 and $error will contain the error ('too_short' o sub is_password_valid { my ($password) = @_; - 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; + } + if ( length($password) < $minPasswordLength ) { return ( 0, 'too_short' ); } -- 2.11.0