From a025f4ca24b17a5018fff02a2fdd8c0773a97df4 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 26 Jun 2017 17:35:45 +0700 Subject: [PATCH] Validate `confirmPassword` in the web installer --- client/coral-admin/src/actions/install.js | 22 +++++++++++++++++++ .../components/Steps/CreateYourAccount.js | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/client/coral-admin/src/actions/install.js b/client/coral-admin/src/actions/install.js index 122ffdc4a..33cefab63 100644 --- a/client/coral-admin/src/actions/install.js +++ b/client/coral-admin/src/actions/install.js @@ -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(); }; diff --git a/client/coral-admin/src/routes/Install/components/Steps/CreateYourAccount.js b/client/coral-admin/src/routes/Install/components/Steps/CreateYourAccount.js index c5d334610..2a5b87e5f 100644 --- a/client/coral-admin/src/routes/Install/components/Steps/CreateYourAccount.js +++ b/client/coral-admin/src/routes/Install/components/Steps/CreateYourAccount.js @@ -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} /> {