Added password criterion support for multiple languages and emojis

This commit is contained in:
Joel Biddle
2023-08-23 01:27:30 +10:00
parent e5c87442e5
commit b2888272f2
8 changed files with 23 additions and 15 deletions

View File

@@ -239,7 +239,7 @@
"validate-number": "at least 1 number",
"validate-special-char": "at least 1 special character",
"validate-repeated-char": "at most 2 repeated consecutive characters",
"validate-is-breached": "The password you provided is in a list of passwords commonly used on other websites. Please try again with a stronger password."
"validate-is-breached": "The new password is in a list of passwords commonly used on other websites. Please try again with a stronger password."
},
"token": {
"service-tokens": "Service Tokens",

View File

@@ -236,7 +236,7 @@
"validate-number": "al menos 1 número",
"validate-special-char": "al menos 1 carácter especial",
"validate-repeated-char": "au plus 2 caracteres consecutivos repetidos",
"validate-breached": "La contraseña que proporcionó se encuentra en una lista de contraseñas comúnmente utilizadas en otros sitios web. Vuelva a intentarlo con una contraseña más segura."
"validate-breached": "La nueva contraseña se encuentra en una lista de contraseñas comúnmente utilizadas en otros sitios web. Vuelva a intentarlo con una contraseña más segura."
},
"token": {
"service-tokens": "Tokens de servicio",

View File

@@ -223,7 +223,7 @@
"validate-number": "au moins 1 chiffre",
"validate-special-char": "au moins 1 caractère spécial",
"validate-repeated-char": "au plus 2 caractères consécutifs répétés",
"validate-is-breached": "Le mot de passe que vous avez fourni figure dans une liste de mots de passe couramment utilisés sur d'autres sites Web. Veuillez réessayer avec un mot de passe plus fort."
"validate-is-breached": "Le nouveau mot de passe se trouve dans une liste de mots de passe couramment utilisés sur d'autres sites Web. Veuillez réessayer avec un mot de passe plus fort."
},
"token": {
"service-tokens": "Jetons de service",

View File

@@ -190,7 +190,7 @@
"validate-number": "숫자 1개 이상",
"validate-special-char": "특수 문자 1개 이상",
"validate-repeated-char": "최대 2개의 반복되는 연속 문자",
"validate-breached": "귀하가 제공한 비밀번호는 다른 웹사이트에서 일반적으로 사용되는 비밀번호 목록에 포함되어 있습니다. 더 강력한 비밀번호로 다시 시도해 주세요."
"validate-breached": "새 비밀번호는 다른 웹사이트에서 일반적으로 사용되는 비밀번호 목록에 있습니다. 더 강력한 비밀번호로 다시 시도해 주세요."
},
"token": {
"add-dialog": {

View File

@@ -218,7 +218,7 @@
"validate-number": "pelo menos 1 número",
"validate-special-char": "pelo menos 1 caractere especial",
"validate-repeated-char": "au plus 2 caractères consécutifs répétés",
"validate-breached": "A senha que você forneceu está em uma lista de senhas comumente usadas em outros sites. Tente novamente com uma senha mais forte."
"validate-breached": "A nova senha está em uma lista de senhas comumente usadas em outros sites. Tente novamente com uma senha mais forte."
},
"token": {
"service-tokens": "Tokens de Serviço",

View File

@@ -236,7 +236,7 @@
"validate-number": "en az 1 sayı",
"validate-special-char": "en az 1 özel karakter",
"validate-repeated-char": "veya artı 2 karakter ardışık tekrar",
"validate-breached": "Sağladığınız şifre, diğer web sitelerinde yaygın olarak kullanılan şifreler listesinde yer almaktadır. Lütfen daha güçlü bir şifre ile tekrar deneyiniz."
"validate-breached": "Yeni şifre, diğer web sitelerinde yaygın olarak kullanılan şifrelerin listesinde yer almaktadır. Lütfen daha güçlü bir şifre ile tekrar deneyiniz."
},
"token": {
"service-tokens": "Servis Belirteçleri",

View File

@@ -46,7 +46,7 @@ const passwordCheck = async ({
}
// upperCase
if (!/[A-Z]/.test(password)) {
if (!/[A-Z\u0041-\u005A\u00C0-\u00D6\u00D8-\u00DE]/.test(password)) {
setPasswordErrorUpperCase(true);
errorCheck = true;
} else {
@@ -54,7 +54,7 @@ const passwordCheck = async ({
}
// lowerCase
if (!/[a-z]/.test(password)) {
if (!/[a-z\u0061-\u007A\u00DF-\u00F6\u00F8-\u00FF]/.test(password)) {
setPasswordErrorLowerCase(true);
errorCheck = true;
} else {
@@ -82,7 +82,11 @@ const passwordCheck = async ({
}
// repeatedChar
if (/([A-Za-z0-9])\1\1\1/.test(password)) {
if (
/([!@#$%^&*(),.?":{}|<>0-9A-Za-z\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\u0600-\u06FF\u0400-\u04FF\u0500-\u052F\u2DE0-\u2DFF\uA640-\uA69F\u05B0-\u05FF\u0980-\u09FF\u1F00-\u1FFF\u0130\u015E\u011E\u00D6\u00C7\u00FC\u00FB\u00F6\u00EB\u00E7\u00C7\u003a-\u003f\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\p{Emoji}])\1\1/.test(
password
)
) {
setPasswordErrorRepeatedChar(true);
errorCheck = true;
} else {

View File

@@ -49,12 +49,12 @@ const checkPassword = async ({ password, setErrors }: CheckPasswordParams): Prom
}
// upperCase
if (!/[A-Z]/.test(password)) {
if (!/[A-Z\u0041-\u005A\u00C0-\u00D6\u00D8-\u00DE]/.test(password)) {
errors.upperCase = "at least 1 uppercase character (A-Z)";
}
// lowerCase
if (!/[a-z]/.test(password)) {
if (!/[a-z\u0061-\u007A\u00DF-\u00F6\u00F8-\u00FF]/.test(password)) {
errors.lowerCase = "at least 1 lowercase character (a-z)";
}
@@ -70,18 +70,22 @@ const checkPassword = async ({ password, setErrors }: CheckPasswordParams): Prom
)
) {
errors.specialChar =
'at least 1 special character (!@#$%^&*(),.?":{}|<>), Japanese, Korean, Arabic, Cyrillic, Greek, Devanagari, Turkish, or an emoji';
'at least 1 special character from !@#$%^&*(),.?":{}|<>, Japanese, Korean, Arabic, Cyrillic, Greek, Devanagari, Turkish, or an emoji';
}
// repeatedChar
if (/([A-Za-z0-9])\1\1\1/.test(password)) {
errors.repeatedChar = "No 3 repeat, consecutive characters";
if (
/([!@#$%^&*(),.?":{}|<>0-9A-Za-z\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\u0600-\u06FF\u0400-\u04FF\u0500-\u052F\u2DE0-\u2DFF\uA640-\uA69F\u05B0-\u05FF\u0980-\u09FF\u1F00-\u1FFF\u0130\u015E\u011E\u00D6\u00C7\u00FC\u00FB\u00F6\u00EB\u00E7\u00C7\u003a-\u003f\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\p{Emoji}])\1\1/.test(
password
)
) {
errors.repeatedChar = "At most 2 repeated, consecutive characters";
}
// breachedPassword
if (await checkIsPasswordBreached(password)) {
errors.isBreachedPassword =
"The provided password is in a list of passwords commonly used on other websites. Please try again with a stronger password.";
"The new password is in a list of passwords commonly used on other websites. Please try again with a stronger password.";
}
setErrors(errors);