mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 11:07:32 +00:00
fix: password check policy correctly (#3787)
* fix: password check policy correctly * fix: password check policy correctly
This commit is contained in:
@@ -10,8 +10,8 @@ function CheckChangePwPolicy() {
|
|||||||
policyElement.setAttribute("color", "primary");
|
policyElement.setAttribute("color", "primary");
|
||||||
}
|
}
|
||||||
|
|
||||||
return pwNew == pwNewConfirmation;
|
return pwNew === pwNewConfirmation;
|
||||||
}
|
}
|
||||||
|
|
||||||
let button = document.getElementById("change-password-button");
|
let button = document.getElementById("change-password-button");
|
||||||
disableSubmit(CheckChangePwPolicy, button);
|
disableSubmit(CheckChangePwPolicy, button);
|
||||||
|
@@ -5,65 +5,59 @@ function ComplexityPolicyCheck(policyElement, pwNew, pwNewConfirmation) {
|
|||||||
let numberRegex = policyElement.dataset.hasNumber;
|
let numberRegex = policyElement.dataset.hasNumber;
|
||||||
let symbolRegex = policyElement.dataset.hasSymbol;
|
let symbolRegex = policyElement.dataset.hasSymbol;
|
||||||
|
|
||||||
let valid = true;
|
let invalid = 0;
|
||||||
|
|
||||||
let minlengthelem = document.getElementById('minlength');
|
let minlengthelem = document.getElementById('minlength');
|
||||||
if (pwNew.length >= minLength) {
|
if (pwNew.length >= minLength) {
|
||||||
ValidPolicy(minlengthelem);
|
ValidPolicy(minlengthelem);
|
||||||
valid = true;
|
|
||||||
} else {
|
} else {
|
||||||
InvalidPolicy(minlengthelem);
|
InvalidPolicy(minlengthelem);
|
||||||
valid = false;
|
invalid++;
|
||||||
}
|
}
|
||||||
let upper = document.getElementById('uppercase');
|
let upper = document.getElementById('uppercase');
|
||||||
if (upperRegex !== "") {
|
if (upperRegex !== "") {
|
||||||
if (RegExp(upperRegex).test(pwNew)) {
|
if (RegExp(upperRegex).test(pwNew)) {
|
||||||
ValidPolicy(upper);
|
ValidPolicy(upper);
|
||||||
valid = true;
|
|
||||||
} else {
|
} else {
|
||||||
InvalidPolicy(upper);
|
InvalidPolicy(upper);
|
||||||
valid = false;
|
invalid++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let lower = document.getElementById('lowercase');
|
let lower = document.getElementById('lowercase');
|
||||||
if (lowerRegex !== "") {
|
if (lowerRegex !== "") {
|
||||||
if (RegExp(lowerRegex).test(pwNew)) {
|
if (RegExp(lowerRegex).test(pwNew)) {
|
||||||
ValidPolicy(lower);
|
ValidPolicy(lower);
|
||||||
valid = true;
|
|
||||||
} else {
|
} else {
|
||||||
InvalidPolicy(lower);
|
InvalidPolicy(lower);
|
||||||
valid = false;
|
invalid++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let number = document.getElementById('number');
|
let number = document.getElementById('number');
|
||||||
if (numberRegex != "") {
|
if (numberRegex !== "") {
|
||||||
if (RegExp(numberRegex).test(pwNew)) {
|
if (RegExp(numberRegex).test(pwNew)) {
|
||||||
ValidPolicy(number);
|
ValidPolicy(number);
|
||||||
valid = true;
|
|
||||||
} else {
|
} else {
|
||||||
InvalidPolicy(number);
|
InvalidPolicy(number);
|
||||||
valid = false;
|
invalid++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let symbol = document.getElementById('symbol');
|
let symbol = document.getElementById('symbol');
|
||||||
if (symbolRegex != "") {
|
if (symbolRegex !== "") {
|
||||||
if (RegExp(symbolRegex).test(pwNew)) {
|
if (RegExp(symbolRegex).test(pwNew)) {
|
||||||
ValidPolicy(symbol);
|
ValidPolicy(symbol);
|
||||||
valid = true;
|
|
||||||
} else {
|
} else {
|
||||||
InvalidPolicy(symbol);
|
InvalidPolicy(symbol);
|
||||||
valid = false;
|
invalid++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let confirmation = document.getElementById('confirmation');
|
let confirmation = document.getElementById('confirmation');
|
||||||
if (pwNew === pwNewConfirmation && pwNewConfirmation !== "" ) {
|
if (pwNew === pwNewConfirmation && pwNewConfirmation !== "" ) {
|
||||||
ValidPolicy(confirmation);
|
ValidPolicy(confirmation);
|
||||||
valid = true;
|
|
||||||
} else {
|
} else {
|
||||||
InvalidPolicy(confirmation);
|
InvalidPolicy(confirmation);
|
||||||
valid = false;
|
invalid++;
|
||||||
}
|
}
|
||||||
return valid;
|
return invalid===0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ValidPolicy(element) {
|
function ValidPolicy(element) {
|
||||||
|
Reference in New Issue
Block a user