diff --git a/GrossesMitaines/grosses-mitaines-ui/src/components/App.js b/GrossesMitaines/grosses-mitaines-ui/src/components/App.js index f832403..761558d 100644 --- a/GrossesMitaines/grosses-mitaines-ui/src/components/App.js +++ b/GrossesMitaines/grosses-mitaines-ui/src/components/App.js @@ -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(); diff --git a/GrossesMitaines/grosses-mitaines-ui/src/components/Topbar.js b/GrossesMitaines/grosses-mitaines-ui/src/components/Topbar.js index 1685b62..b8d888f 100644 --- a/GrossesMitaines/grosses-mitaines-ui/src/components/Topbar.js +++ b/GrossesMitaines/grosses-mitaines-ui/src/components/Topbar.js @@ -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() { diff --git a/GrossesMitaines/grosses-mitaines-ui/src/pages/Login.js b/GrossesMitaines/grosses-mitaines-ui/src/pages/Login.js index e229e15..2862497 100644 --- a/GrossesMitaines/grosses-mitaines-ui/src/pages/Login.js +++ b/GrossesMitaines/grosses-mitaines-ui/src/pages/Login.js @@ -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);