|
|
|
@ -21,22 +21,22 @@ export const matchesHash = (phrase: string | null, hash: string) =>
|
|
|
|
|
|
|
|
|
|
export const validatePassword = (phrase: string) => {
|
|
|
|
|
if (!isString(phrase)) {
|
|
|
|
|
return window?.i18n ? window?.i18n('passwordError') : ERRORS.TYPE;
|
|
|
|
|
return window?.i18n ? window.i18n('passwordError') : ERRORS.TYPE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const trimmed = phrase.trim();
|
|
|
|
|
if (trimmed.length === 0) {
|
|
|
|
|
return window?.i18n ? window?.i18n('passwordCreate') : ERRORS.LENGTH;
|
|
|
|
|
return window?.i18n ? window.i18n('passwordCreate') : ERRORS.LENGTH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (trimmed.length < 6 || trimmed.length > MAX_PASSWORD_LENGTH) {
|
|
|
|
|
return window?.i18n ? window?.i18n('passwordErrorLength') : ERRORS.LENGTH;
|
|
|
|
|
return window?.i18n ? window.i18n('passwordErrorLength') : ERRORS.LENGTH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Restrict characters to letters, numbers and symbols
|
|
|
|
|
const characterRegex = /^[a-zA-Z0-9-!?/\\()._`~@#$%^&*+=[\]{}|<>,;: ]+$/;
|
|
|
|
|
if (!characterRegex.test(trimmed)) {
|
|
|
|
|
return window?.i18n ? window?.i18n('passwordError') : ERRORS.CHARACTER;
|
|
|
|
|
return window?.i18n ? window.i18n('passwordError') : ERRORS.CHARACTER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|