Allow all special chars (#2266)

This commit is contained in:
Christophe Maudoux 2020-08-29 22:12:09 +02:00
parent 7a9020ff25
commit 01beb5d48b
5 changed files with 54 additions and 20 deletions

View File

@ -2,7 +2,7 @@
# Display functions for LemonLDAP::NG Portal
package Lemonldap::NG::Portal::Main::Display;
our $VERSION = '2.0.9';
our $VERSION = '2.0.10';
package Lemonldap::NG::Portal::Main;
use strict;
@ -40,7 +40,10 @@ sub displayInit {
}
$self->requireOldPwd($rule);
my $speChars = $self->conf->{passwordPolicySpecialChar};
my $speChars =
$self->conf->{passwordPolicySpecialChar} eq '__ALL__'
? ''
: $self->conf->{passwordPolicySpecialChar};
$speChars =~ s/\s+/ /g;
$speChars =~ s/(?:^\s|\s$)//g;
$self->speChars($speChars);
@ -238,18 +241,17 @@ sub display {
PING => $self->conf->{portalPingInterval},
REQUIRE_OLDPASSWORD =>
$self->requireOldPwd->( $req, $req->userData ),
HIDE_OLDPASSWORD => 0,
DISPLAY_PPOLICY => $self->conf->{portalDisplayPasswordPolicy},
PPOLICY_MINSIZE => $self->conf->{passwordPolicyMinSize},
PPOLICY_MINLOWER => $self->conf->{passwordPolicyMinLower},
PPOLICY_MINUPPER => $self->conf->{passwordPolicyMinUpper},
PPOLICY_MINDIGIT => $self->conf->{passwordPolicyMinDigit},
PPOLICY_NOPOLICY => !$self->isPP(),
PPOLICY_ALLOWEDSPECHAR => $self->speChars(),
HIDE_OLDPASSWORD => 0,
PPOLICY_NOPOLICY => !$self->isPP(),
DISPLAY_PPOLICY => $self->conf->{portalDisplayPasswordPolicy},
PPOLICY_MINSIZE => $self->conf->{passwordPolicyMinSize},
PPOLICY_MINLOWER => $self->conf->{passwordPolicyMinLower},
PPOLICY_MINUPPER => $self->conf->{passwordPolicyMinUpper},
PPOLICY_MINDIGIT => $self->conf->{passwordPolicyMinDigit},
PPOLICY_MINSPECHAR => $self->conf->{passwordPolicyMinSpeChar},
(
$self->speChars()
? ( PPOLICY_MINSPECHAR =>
$self->conf->{passwordPolicyMinSpeChar} )
$self->conf->{passwordPolicyMinSpeChar}
? ( PPOLICY_ALLOWEDSPECHAR => $self->speChars() )
: ()
),
$self->menu->params($req),
@ -406,17 +408,16 @@ sub display {
$req->data->{oldpassword} ) ? ""
: $req->data->{oldpassword},
HIDE_OLDPASSWORD => $self->conf->{hideOldPassword},
PPOLICY_NOPOLICY => !$self->isPP(),
DISPLAY_PPOLICY => $self->conf->{portalDisplayPasswordPolicy},
PPOLICY_MINSIZE => $self->conf->{passwordPolicyMinSize},
PPOLICY_MINLOWER => $self->conf->{passwordPolicyMinLower},
PPOLICY_MINUPPER => $self->conf->{passwordPolicyMinUpper},
PPOLICY_MINDIGIT => $self->conf->{passwordPolicyMinDigit},
PPOLICY_NOPOLICY => !$self->isPP(),
PPOLICY_ALLOWEDSPECHAR => $self->speChars(),
PPOLICY_MINSPECHAR => $self->conf->{passwordPolicyMinSpeChar},
(
$self->speChars()
? ( PPOLICY_MINSPECHAR =>
$self->conf->{passwordPolicyMinSpeChar} )
$self->conf->{passwordPolicyMinSpeChar}
? ( PPOLICY_ALLOWEDSPECHAR => $self->speChars() )
: ()
),
);

View File

@ -459,6 +459,21 @@ $(window).on 'load', () ->
$('#ppolicy-minspechar-feedback').removeClass 'fa-check text-success'
$('#ppolicy-minspechar-feedback').addClass 'fa-times text-danger'
result = false
if window.datas.ppolicy.minspechar > 0 and !window.datas.ppolicy.allowedspechar
numspechar = 0
i = 0
while i < password.length
numspechar++ if !isAlphaNumeric(password.charAt(i))
i++
if numspechar >= window.datas.ppolicy.minspechar
$('#ppolicy-minspechar-feedback').addClass 'fa-check text-success'
$('#ppolicy-minspechar-feedback').removeClass 'fa-times text-danger'
else
$('#ppolicy-minspechar-feedback').removeClass 'fa-check text-success'
$('#ppolicy-minspechar-feedback').addClass 'fa-times text-danger'
result = false
if result
$('.ppolicy').removeClass('border-danger').addClass 'border-success'
$('#newpassword')[0].setCustomValidity('')

View File

@ -494,6 +494,24 @@ LemonLDAP::NG Portal jQuery scripts
result = false;
}
}
if (window.datas.ppolicy.minspechar > 0 && !window.datas.ppolicy.allowedspechar) {
numspechar = 0;
i = 0;
while (i < password.length) {
if (!isAlphaNumeric(password.charAt(i))) {
numspechar++;
}
i++;
}
if (numspechar >= window.datas.ppolicy.minspechar) {
$('#ppolicy-minspechar-feedback').addClass('fa-check text-success');
$('#ppolicy-minspechar-feedback').removeClass('fa-times text-danger');
} else {
$('#ppolicy-minspechar-feedback').removeClass('fa-check text-success');
$('#ppolicy-minspechar-feedback').addClass('fa-times text-danger');
result = false;
}
}
if (result) {
$('.ppolicy').removeClass('border-danger').addClass('border-success');
$('#newpassword')[0].setCustomValidity('');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long