mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-23 16:13:50 +00:00
display of correct message for 403 error fixed + translation
This commit is contained in:
@@ -21,7 +21,7 @@ const makeFetch = (method, url, body) => {
|
||||
}
|
||||
|
||||
if (response.status === 403) {
|
||||
throw AccessException();
|
||||
throw AccessException(response);
|
||||
}
|
||||
|
||||
throw {
|
||||
@@ -86,15 +86,21 @@ const ValidationException = (response) => {
|
||||
error.violations = response.violations.map((violation) => `${violation.title}: ${violation.propertyPath}`);
|
||||
error.titles = response.violations.map((violation) => violation.title);
|
||||
error.propertyPaths = response.violations.map((violation) => violation.propertyPath);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
const AccessException = () => {
|
||||
const AccessException = (response) => {
|
||||
const error = {};
|
||||
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user