LoginLogout
This commit is contained in:
parent
0ffa974bd3
commit
3f6c303865
@ -1,5 +1,6 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Button } from "react-bootstrap";
|
import { Button } from "react-bootstrap";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
const Login = () => {
|
const Login = () => {
|
||||||
const [rememberme, setPersistence] = useState(true);
|
const [rememberme, setPersistence] = useState(true);
|
||||||
@ -7,6 +8,8 @@ const Login = () => {
|
|||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
const [returnmess, returnMessage] = useState("");
|
const [returnmess, returnMessage] = useState("");
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const handleLogin = async (e) => {
|
const handleLogin = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@ -31,9 +34,7 @@ const Login = () => {
|
|||||||
'Content-Type': 'text/json'
|
'Content-Type': 'text/json'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// TODO: Redirection vers Home et ajout du cookie pour React pour le layout.
|
navigate("/");
|
||||||
console.log(await confirm.json())
|
|
||||||
returnMessage("WOOHOO!");
|
|
||||||
}
|
}
|
||||||
else returnMessage("L'adresse courriel ou le mot de passe est incorrect.");
|
else returnMessage("L'adresse courriel ou le mot de passe est incorrect.");
|
||||||
}
|
}
|
||||||
@ -64,9 +65,6 @@ const Login = () => {
|
|||||||
onChange={(e) => setPassword(e.target.value)} />
|
onChange={(e) => setPassword(e.target.value)} />
|
||||||
</div>
|
</div>
|
||||||
<Button className="btn-primary btn-ajouter-morceau" type="submit" >Connexion</Button>
|
<Button className="btn-primary btn-ajouter-morceau" type="submit" >Connexion</Button>
|
||||||
<Button className="btn-primary btn-ajouter-morceau" type="button" >
|
|
||||||
<a href="http://localhost:3000/register">Nouvel utilisateur</a>
|
|
||||||
</Button>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
const Logout = () => {
|
const Logout = () => {
|
||||||
const response = fetch(`https://localhost:7292/api/Logout`, {
|
const response = fetch(`https://localhost:7292/api/Logout`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
credentials: 'include'
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user