implementado login a travez de coockies

This commit is contained in:
2024-10-31 17:58:32 -03:00
parent d75d6c52b6
commit 34c995d5f9
9 changed files with 67 additions and 63 deletions

View File

@@ -10,7 +10,7 @@
export let component;
let redirect = window.location.pathname;
const token = localStorage.getItem('token');
const email = localStorage.getItem('email');
const handleAccess = async () => {
@@ -20,7 +20,8 @@
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify( {email, token, redirect} ),
body: JSON.stringify( {email, redirect} ),
credentials: "include"
});
if (response.ok) {

View File

@@ -18,7 +18,8 @@
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
body: JSON.stringify(data),
credentials: "include"
});
if (!response.ok){
@@ -30,7 +31,6 @@
const ret = await response.json();
localStorage.clear();
localStorage.setItem('token', ret.token);
localStorage.setItem('email', ret.email);
//setTimeout(() => console.log("50ms") ,50);
navigate(ret.redirect);