Ajout de la connexion utilisateur

This commit is contained in:
Dayamond committed 2025-10-18 16:48:27 +02:00
1 parent 05eed05947
commit 387b2c32cf
4 files changed
+86 -5

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
export default async function getXSRFToken() {
const response = await fetch('http://localhost:8000/sanctum/csrf-cookie', {
method: 'GET',
credentials: 'include'
});
if (!response.ok && response.status !== 204) {
throw new Error(`Error : ${response.status}`);
}
const name = 'XSRF-TOKEN';
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) {
return decodeURIComponent(parts.pop().split(';').shift());
}
throw new Error('Error: Invalid XSRF-TOKEN');
}