File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 712
712
"passwordEnterCurrent" : " Please enter your current password" ,
713
713
"passwordEnterNew" : " Please enter your new password" ,
714
714
"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" ,
716
716
"passwordErrorMatch" : " Passwords do not match" ,
717
717
"passwordFailed" : " Failed to set password" ,
718
718
"passwordIncorrect" : " Incorrect password" ,
Original file line number Diff line number Diff line change @@ -13,20 +13,25 @@ export const generateHash = (phrase: string) => phrase && sha512(phrase);
13
13
export const matchesHash = ( phrase : string | null , hash : string ) =>
14
14
phrase && sha512 ( phrase ) === hash ;
15
15
16
+ const passwordArgs = {
17
+ min : PASSWORD_LENGTH . MIN_PASSWORD_LEN . toString ( ) ,
18
+ max : PASSWORD_LENGTH . MAX_PASSWORD_LEN . toString ( ) ,
19
+ } ;
20
+
16
21
export const validatePassword = ( phrase : string ) => {
17
22
if ( ! isString ( phrase ) ) {
18
23
return tr ( 'passwordError' ) ;
19
24
}
20
25
21
26
if ( phrase . length === 0 ) {
22
- return tr ( 'passwordErrorLength' ) ;
27
+ return tr ( 'passwordErrorLength' , passwordArgs ) ;
23
28
}
24
29
25
30
if (
26
31
phrase . length < PASSWORD_LENGTH . MIN_PASSWORD_LEN ||
27
32
phrase . length > PASSWORD_LENGTH . MAX_PASSWORD_LEN
28
33
) {
29
- return tr ( 'passwordErrorLength' ) ;
34
+ return tr ( 'passwordErrorLength' , passwordArgs ) ;
30
35
}
31
36
32
37
// Restrict characters to letters, numbers and symbols
You can’t perform that action at this time.
0 commit comments