internationalize password requirements

This commit is contained in:
Joel Biddle
2023-08-23 00:48:45 +10:00
parent 61e44e152c
commit be08417c8b
2 changed files with 14 additions and 5 deletions

View File

@@ -70,7 +70,11 @@ const passwordCheck = async ({
} }
// specialChar // specialChar
if (!/[!@#$%^&*(),.?":{}|<>]/.test(password)) { if (
!/[!@#$%^&*(),.?":{}|<>\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}\p{Script=Arabic}\p{Script=Cyrillic}\p{Script=Cyrillic_Supplement}\p{Script=Cyrillic_Extended_A}\p{Script=Cyrillic_Extended_B}\p{Script=Cyrillic_Extended_C}\p{Script=Cyrillic_Extended_D}\p{Script=Ukrainian}\p{Script=Farsi}\p{Emoji}]/u.test(
password
)
) {
setPasswordErrorSpecialChar(true); setPasswordErrorSpecialChar(true);
errorCheck = true; errorCheck = true;
} else { } else {

View File

@@ -43,7 +43,7 @@ const checkPassword = async ({ password, setErrors }: CheckPasswordParams): Prom
errors.tooShort = "at least 14 characters"; errors.tooShort = "at least 14 characters";
} }
// toolong // tooLong
if (password.length > 100) { if (password.length > 100) {
errors.tooLong = "at most 100 characters"; errors.tooLong = "at most 100 characters";
} }
@@ -64,8 +64,13 @@ const checkPassword = async ({ password, setErrors }: CheckPasswordParams): Prom
} }
// specialChar // specialChar
if (!/[!@#$%^&*(),.?":{}|<>]/.test(password)) { if (
errors.specialChar = "at least 1 special character (!@#$%^&*(),.?)"; !/[!@#$%^&*(),.?":{}|<>\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}\p{Script=Arabic}\p{Script=Cyrillic}\p{Script=Cyrillic_Supplement}\p{Script=Cyrillic_Extended_A}\p{Script=Cyrillic_Extended_B}\p{Script=Cyrillic_Extended_C}\p{Script=Cyrillic_Extended_D}\p{Script=Ukrainian}\p{Script=Farsi}\p{Emoji}]/u.test(
password
)
) {
errors.specialChar =
'at least 1 special character (!@#$%^&*(),.?":{}|<>), Japanese, Korean, Arabic, Cyrillic, Ukrainian, Farsi, or an emoji';
} }
// repeatedChar // repeatedChar
@@ -76,7 +81,7 @@ const checkPassword = async ({ password, setErrors }: CheckPasswordParams): Prom
// breachedPassword // breachedPassword
if (await checkIsPasswordBreached(password)) { if (await checkIsPasswordBreached(password)) {
errors.isBreachedPassword = errors.isBreachedPassword =
"The password you provided is in a list of passwords commonly used on other websites. Please try again with a stronger password."; "The provided password is in a list of passwords commonly used on other websites. Please try again with a stronger password.";
} }
setErrors(errors); setErrors(errors);