Skip to content

Commit d0eed6a

Browse files
committed
fix: update password error string to use variables
1 parent ded9c81 commit d0eed6a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

_locales/en/messages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@
712712
"passwordEnterCurrent": "Please enter your current password",
713713
"passwordEnterNew": "Please enter your new password",
714714
"passwordError": "Password must only contain letters, numbers and symbols",
715-
"passwordErrorLength": "Password must be between 6 and 256 characters long",
715+
"passwordErrorLength": "Password must be between {min} and {max} characters long",
716716
"passwordErrorMatch": "Passwords do not match",
717717
"passwordFailed": "Failed to set password",
718718
"passwordIncorrect": "Incorrect password",

ts/util/passwordUtils.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,25 @@ export const generateHash = (phrase: string) => phrase && sha512(phrase);
1313
export const matchesHash = (phrase: string | null, hash: string) =>
1414
phrase && sha512(phrase) === hash;
1515

16+
const passwordArgs = {
17+
min: PASSWORD_LENGTH.MIN_PASSWORD_LEN.toString(),
18+
max: PASSWORD_LENGTH.MAX_PASSWORD_LEN.toString(),
19+
};
20+
1621
export const validatePassword = (phrase: string) => {
1722
if (!isString(phrase)) {
1823
return tr('passwordError');
1924
}
2025

2126
if (phrase.length === 0) {
22-
return tr('passwordErrorLength');
27+
return tr('passwordErrorLength', passwordArgs);
2328
}
2429

2530
if (
2631
phrase.length < PASSWORD_LENGTH.MIN_PASSWORD_LEN ||
2732
phrase.length > PASSWORD_LENGTH.MAX_PASSWORD_LEN
2833
) {
29-
return tr('passwordErrorLength');
34+
return tr('passwordErrorLength', passwordArgs);
3035
}
3136

3237
// Restrict characters to letters, numbers and symbols

0 commit comments

Comments
 (0)