Add keywords
This commit is contained in:
parent
58df9de5d0
commit
fabf883857
1 changed files with 3 additions and 1 deletions
|
@ -36,6 +36,8 @@ const CONFIRM_PASSWORD_ERROR = 'Passwords don\'t match.';
|
||||||
const EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
|
const EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
|
||||||
const BAD_EMAIL_ERROR = 'Invalid email address';
|
const BAD_EMAIL_ERROR = 'Invalid email address';
|
||||||
|
|
||||||
|
const MATRIX_KEYWORDS = ['matrix', 'cinny', 'element', 'synapse', 'dendrite'];
|
||||||
|
|
||||||
function isValidInput(value, regex) {
|
function isValidInput(value, regex) {
|
||||||
if (typeof regex === 'string') return regex === value;
|
if (typeof regex === 'string') return regex === value;
|
||||||
return regex.test(value);
|
return regex.test(value);
|
||||||
|
@ -317,7 +319,7 @@ function Register({ registerInfo, loginFlow, baseUrl }) {
|
||||||
errors.username = BAD_LOCALPART_ERROR;
|
errors.username = BAD_LOCALPART_ERROR;
|
||||||
}
|
}
|
||||||
if (values.password.length > 0) {
|
if (values.password.length > 0) {
|
||||||
const result = zxcvbn(values.password);
|
const result = zxcvbn(values.password, [...MATRIX_KEYWORDS, values.username, values.email]);
|
||||||
if (result.feedback) {
|
if (result.feedback) {
|
||||||
errors.password = result.feedback.warning;
|
errors.password = result.feedback.warning;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue