react-version #1
@ -23,9 +23,9 @@ const App = () => {
|
|||||||
const response = await fetch(`https://localhost:7292/api/WhoAmI`, { credentials: 'include' });
|
const response = await fetch(`https://localhost:7292/api/WhoAmI`, { credentials: 'include' });
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
var user = await response.json();
|
var user = await response.json();
|
||||||
setCookie('GMGM', {...user, LoggedIn:true}, { path: '/', SameSite:'strict' })
|
setCookie('GMGM', {...user, LoggedIn:true}, { path: '/', SameSite:'strict', secure:true })
|
||||||
}
|
}
|
||||||
else setCookie('GMGM', {LoggedIn:false}, { path: '/', SameSite:'strict' })
|
else setCookie('GMGM', {LoggedIn:false}, { path: '/', SameSite:'strict', secure:true })
|
||||||
}
|
}
|
||||||
if (cookies.GMGM === null) {
|
if (cookies.GMGM === null) {
|
||||||
FetchUser();
|
FetchUser();
|
||||||
|
@ -11,7 +11,10 @@ const Topbar = () => {
|
|||||||
const [cookies, setCookie, removeCookie] = useCookies(['name']);
|
const [cookies, setCookie, removeCookie] = useCookies(['name']);
|
||||||
const [user, setLogin] = useState(null);
|
const [user, setLogin] = useState(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLogin(cookies.GMGM ?? null);
|
async function reset() {
|
||||||
|
await setLogin(await cookies.GMGM ?? null);
|
||||||
|
}
|
||||||
|
reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
async function logOut() {
|
async function logOut() {
|
||||||
|
@ -39,17 +39,17 @@ const Login = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
const user = await confirm.json();
|
const user = await confirm.json();
|
||||||
setCookie('GMGM', {...user, LoggedIn:true}, { path: '/', SameSite:'strict' })
|
setCookie('GMGM', {...user, LoggedIn:true}, { path: '/', SameSite:'strict', secure:true })
|
||||||
navigate("/");
|
navigate("/");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
returnMessage("L'adresse courriel ou le mot de passe est incorrect.");
|
returnMessage("L'adresse courriel ou le mot de passe est incorrect.");
|
||||||
setCookie('GMGM', {LoggedIn:false}, { path: '/', SameSite:'strict' })
|
setCookie('GMGM', {LoggedIn:false}, { path: '/', SameSite:'strict', secure:true })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
returnMessage("Erreur d'API, veuillez réessayer plus tard.")
|
returnMessage("Erreur d'API, veuillez réessayer plus tard.")
|
||||||
setCookie('GMGM', {LoggedIn:false}, { path: '/', SameSite:'strict' })
|
setCookie('GMGM', {LoggedIn:false}, { path: '/', SameSite:'strict', secure:true })
|
||||||
}
|
}
|
||||||
setPassword("");
|
setPassword("");
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user