add errors for any param validation failures to the snackbar (#10724)

This commit is contained in:
Kirsty
2018-10-08 20:54:05 +01:00
committed by Matteo Pagliazzi
parent cfc0f6a3ac
commit 67a8eebb96

View File

@@ -329,23 +329,13 @@ export default {
if (notificationNotFoundMessage.indexOf(errorMessage) !== -1) snackbarTimeout = true;
let errorsToShow = [];
let usernameCheck = false;
let emailCheck = false;
let passwordCheck = false;
// show only the first error for each param
let paramErrorsFound = {};
if (errorData.errors) {
for (let e of errorData.errors) {
if (!usernameCheck && e.param === 'username') {
if (!paramErrorsFound[e.param]) {
errorsToShow.push(e.message);
usernameCheck = true;
}
if (!emailCheck && e.param === 'email') {
errorsToShow.push(e.message);
emailCheck = true;
}
if (!passwordCheck && e.param === 'password') {
errorsToShow.push(e.message);
passwordCheck = true;
paramErrorsFound[e.param] = true;
}
}
} else {