react-version #1
@ -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();
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user