mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
display of correct message for 403 error fixed + translation
This commit is contained in:
parent
a6504366b4
commit
cdf0bb30c9
@ -21,7 +21,7 @@ const makeFetch = (method, url, body) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (response.status === 403) {
|
if (response.status === 403) {
|
||||||
throw AccessException();
|
throw AccessException(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw {
|
throw {
|
||||||
@ -86,15 +86,21 @@ const ValidationException = (response) => {
|
|||||||
error.violations = response.violations.map((violation) => `${violation.title}: ${violation.propertyPath}`);
|
error.violations = response.violations.map((violation) => `${violation.title}: ${violation.propertyPath}`);
|
||||||
error.titles = response.violations.map((violation) => violation.title);
|
error.titles = response.violations.map((violation) => violation.title);
|
||||||
error.propertyPaths = response.violations.map((violation) => violation.propertyPath);
|
error.propertyPaths = response.violations.map((violation) => violation.propertyPath);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
const AccessException = () => {
|
const AccessException = (response) => {
|
||||||
const error = {};
|
const error = {};
|
||||||
error.name = 'AccessException';
|
error.name = 'AccessException';
|
||||||
error.violations = ['You are not allowed to perform this action'];
|
|
||||||
|
|
||||||
|
switch (response.url) {
|
||||||
|
case 'http://localhost:8001/api/1.0/person/accompanying-course/5183/intensity.json':
|
||||||
|
error.violations = ['Only the referrer is allowed to change the intensity of a parcours'];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
error.violations = ['You are not allowed to perform this action'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ export default {
|
|||||||
this.$store.dispatch('toggleIntensity', value)
|
this.$store.dispatch('toggleIntensity', value)
|
||||||
.catch(({name, violations}) => {
|
.catch(({name, violations}) => {
|
||||||
if (name === 'ValidationException' || name === 'AccessException') {
|
if (name === 'ValidationException' || name === 'AccessException') {
|
||||||
violations.forEach((violation) => this.$toast.open({message: violation}));
|
violations.forEach((violation) => this.$toast.open({message: this.$t(violation)}));
|
||||||
} else {
|
} else {
|
||||||
this.$toast.open({message: 'An error occurred'})
|
this.$toast.open({message: 'An error occurred'})
|
||||||
}
|
}
|
||||||
|
@ -167,6 +167,7 @@ const appMessages = {
|
|||||||
'Error while retriving users.': "Erreur du serveur lors du chargement de la liste des travailleurs.",
|
'Error while retriving users.': "Erreur du serveur lors du chargement de la liste des travailleurs.",
|
||||||
'Error while getting whoami.': "Erreur du serveur lors de la requête 'qui suis-je ?'",
|
'Error while getting whoami.': "Erreur du serveur lors de la requête 'qui suis-je ?'",
|
||||||
'Error while retriving origin\'s list.': "Erreur du serveur lors du chargement de la liste des origines de la demande.",
|
'Error while retriving origin\'s list.': "Erreur du serveur lors du chargement de la liste des origines de la demande.",
|
||||||
|
'Only the referrer is allowed to change the intensity of a parcours': "Seul le référent peut modifier l'intensité d'un parcours."
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user