Validate confirmPassword in the web installer

This commit is contained in:
Chi Vinh Le
2017-06-26 17:35:45 +07:00
parent e2a9a42ec6
commit a025f4ca24
2 changed files with 23 additions and 1 deletions
+22
View File
@@ -66,6 +66,28 @@ const validation = (formData, dispatch, next) => {
return;
}
// Confirm Validation
const prefixLength = 'confirm'.length;
const confirm = validKeys
.filter((name) => {
if (!name.startsWith('confirm')) {
return false;
}
// Check that 'confirmX' equals 'X'.
const other = name.substr(prefixLength, 1).toLowerCase() + name.substr(prefixLength + 1);
const cond = formData[other] !== formData[name];
if (cond) {
dispatch(addError(name, errorMsj[name]));
}
return cond;
});
if (confirm.length) {
dispatch(hasError());
return;
}
dispatch(clearErrors());
next();
};
@@ -48,7 +48,7 @@ const InitialStep = (props) => {
label={t('install.create.confirm_password')}
onChange={handleUserChange}
showErrors={install.showErrors}
errorMsg={install.errors.confirm_password}
errorMsg={install.errors.confirmPassword}
/>
{