Merge pull request #713 from coralproject/validate-confirm-password

Validate `confirmPassword` in the web installer
This commit is contained in:
Kim Gardner
2017-06-26 12:25:16 +01:00
committed by GitHub
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}
/>
{