feat: Securisation du Backend

This commit is contained in:
Luc SORIGNET
2026-02-27 10:45:36 +01:00
parent 2fef6d61a4
commit fa843097ba
55 changed files with 2898 additions and 910 deletions

View File

@ -1,49 +1,31 @@
import { BE_PLANNING_PLANNINGS_URL, BE_PLANNING_EVENTS_URL } from '@/utils/Url';
import { errorHandler, requestResponseHandler } from './actionsHandlers';
import { fetchWithAuth } from '@/utils/fetchWithAuth';
const getData = (url) => {
return fetch(`${url}`).then(requestResponseHandler).catch(errorHandler);
return fetchWithAuth(url);
};
const createDatas = (url, newData, csrfToken) => {
return fetch(url, {
return fetchWithAuth(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfToken,
},
headers: { 'X-CSRFToken': csrfToken },
body: JSON.stringify(newData),
credentials: 'include',
})
.then(requestResponseHandler)
.catch(errorHandler);
});
};
const updateDatas = (url, updatedData, csrfToken) => {
return fetch(`${url}`, {
return fetchWithAuth(url, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfToken,
},
headers: { 'X-CSRFToken': csrfToken },
body: JSON.stringify(updatedData),
credentials: 'include',
})
.then(requestResponseHandler)
.catch(errorHandler);
});
};
const removeDatas = (url, csrfToken) => {
return fetch(`${url}`, {
return fetchWithAuth(url, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfToken,
},
credentials: 'include',
})
.then(requestResponseHandler)
.catch(errorHandler);
headers: { 'X-CSRFToken': csrfToken },
});
};
export const fetchPlannings = (