This commit is contained in:
MarcEricMartel 2022-11-06 08:31:20 -08:00
parent 43cd2bd7c2
commit 64e87477d4
3 changed files with 9 additions and 6 deletions

View File

@ -23,9 +23,9 @@ const App = () => {
const response = await fetch(`https://localhost:7292/api/WhoAmI`, { credentials: 'include' });
if (response.status === 200) {
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) {
FetchUser();

View File

@ -11,7 +11,10 @@ const Topbar = () => {
const [cookies, setCookie, removeCookie] = useCookies(['name']);
const [user, setLogin] = useState(null);
useEffect(() => {
setLogin(cookies.GMGM ?? null);
async function reset() {
await setLogin(await cookies.GMGM ?? null);
}
reset();
});
async function logOut() {

View File

@ -39,17 +39,17 @@ const Login = () => {
}
});
const user = await confirm.json();
setCookie('GMGM', {...user, LoggedIn:true}, { path: '/', SameSite:'strict' })
setCookie('GMGM', {...user, LoggedIn:true}, { path: '/', SameSite:'strict', secure:true })
navigate("/");
}
else {
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 {
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("");
setLoading(false);