implementado login a travez de coockies
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user