{
+ const [cookies, setCookie] = useCookies(['name']);
const [rememberme, setPersistence] = useState(true);
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
@@ -34,11 +36,19 @@ const Login = () => {
'Content-Type': 'text/json'
}
});
+ const user = await confirm.json();
+ setCookie('GMGM', {...user, LoggedIn:true}, { path: '/', sameSite:'strict' })
navigate("/");
}
- else returnMessage("L'adresse courriel ou le mot de passe est incorrect.");
+ else {
+ returnMessage("L'adresse courriel ou le mot de passe est incorrect.");
+ setCookie('GMGM', {LoggedIn:false}, { path: '/', sameSite:'strict' })
+ }
}
- else returnMessage("Erreur d'API, veuillez réessayer plus tard.")
+ else {
+ returnMessage("Erreur d'API, veuillez réessayer plus tard.")
+ setCookie('GMGM', {LoggedIn:false}, { path: '/', sameSite:'strict' })
+ }
setPassword("");
}
diff --git a/GrossesMitaines/grosses-mitaines-ui/src/pages/Logout.js b/GrossesMitaines/grosses-mitaines-ui/src/pages/Logout.js
index 94298f2..82f8862 100644
--- a/GrossesMitaines/grosses-mitaines-ui/src/pages/Logout.js
+++ b/GrossesMitaines/grosses-mitaines-ui/src/pages/Logout.js
@@ -1,10 +1,22 @@
+import { useCookies } from "react-cookie";
+import { useNavigate } from "react-router-dom";
+import { useEffect } from "react";
const Logout = () => {
+ const navigate = useNavigate();
+ const [cookies, setCookie, removeCookie] = useCookies(['name']);
+
const response = fetch(`https://localhost:7292/api/Logout`, {
method: 'POST',
credentials: 'include'
})
+ removeCookie("GMGM");
+
+ useEffect(()=>{
+ navigate("/");
+ });
+
return (
Vous n'êtes plus connecté!