mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
add errors for any param validation failures to the snackbar (#10724)
This commit is contained in:
@@ -329,23 +329,13 @@ export default {
|
|||||||
if (notificationNotFoundMessage.indexOf(errorMessage) !== -1) snackbarTimeout = true;
|
if (notificationNotFoundMessage.indexOf(errorMessage) !== -1) snackbarTimeout = true;
|
||||||
|
|
||||||
let errorsToShow = [];
|
let errorsToShow = [];
|
||||||
let usernameCheck = false;
|
|
||||||
let emailCheck = false;
|
|
||||||
let passwordCheck = false;
|
|
||||||
// show only the first error for each param
|
// show only the first error for each param
|
||||||
|
let paramErrorsFound = {};
|
||||||
if (errorData.errors) {
|
if (errorData.errors) {
|
||||||
for (let e of errorData.errors) {
|
for (let e of errorData.errors) {
|
||||||
if (!usernameCheck && e.param === 'username') {
|
if (!paramErrorsFound[e.param]) {
|
||||||
errorsToShow.push(e.message);
|
errorsToShow.push(e.message);
|
||||||
usernameCheck = true;
|
paramErrorsFound[e.param] = true;
|
||||||
}
|
|
||||||
if (!emailCheck && e.param === 'email') {
|
|
||||||
errorsToShow.push(e.message);
|
|
||||||
emailCheck = true;
|
|
||||||
}
|
|
||||||
if (!passwordCheck && e.param === 'password') {
|
|
||||||
errorsToShow.push(e.message);
|
|
||||||
passwordCheck = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user