react-version #1

Merged
memartel_loc merged 290 commits from react-version into main 2023-11-04 09:48:15 -04:00
3 changed files with 9 additions and 6 deletions
Showing only changes of commit 64e87477d4 - Show all commits

View File

@ -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();

View File

@ -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() {

View File

@ -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);