Fix password validation error messages (#34030)

Closes #33987

Signed-off-by: SebastEnn <103125747+SebastEnn@users.noreply.github.com>
This commit is contained in:
SebastEnn 2024-10-21 12:47:24 +02:00 committed by GitHub
parent c5d26bd45d
commit ece97f3a41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -63,8 +63,6 @@
<script type="module">
import { validatePassword } from "${url.resourcesPath}/js/password-policy.js";
const template = document.querySelector("#errorTemplate").content.cloneNode(true);
const activePolicies = [
{ name: "length", policy: { value: ${passwordPolicies.length!-1}, error: "${msg('invalidPasswordMinLengthMessage')}"} },
{ name: "maxLength", policy: { value: ${passwordPolicies.maxLength!-1}, error: "${msg('invalidPasswordMaxLengthMessage')}"} },
@ -79,6 +77,9 @@
if (serverErrors) {
serverErrors.remove();
}
const template = document.querySelector("#errorTemplate").content.cloneNode(true);
const errors = validatePassword(event.target.value, activePolicies);
const errorList = template.querySelector("ul");
const htmlErrors = errors.forEach((e) => {
@ -87,7 +88,7 @@
li.textContent = e;
errorList.appendChild(li);
});
document.getElementById("input-error-client-password").appendChild(template);
document.getElementById("input-error-client-password").replaceChildren(template);
});
</script>
</#if>