diff --git a/GrossesMitaines/GrossesMitainesAPI/Controllers/LoginController.cs b/GrossesMitaines/GrossesMitainesAPI/Controllers/LoginController.cs index 296da5c..214fffe 100644 --- a/GrossesMitaines/GrossesMitainesAPI/Controllers/LoginController.cs +++ b/GrossesMitaines/GrossesMitainesAPI/Controllers/LoginController.cs @@ -61,4 +61,3 @@ public class LoginController : Controller { #endregion } - diff --git a/GrossesMitaines/GrossesMitainesAPI/Program.cs b/GrossesMitaines/GrossesMitainesAPI/Program.cs index 26972a0..347b7fd 100644 --- a/GrossesMitaines/GrossesMitainesAPI/Program.cs +++ b/GrossesMitaines/GrossesMitainesAPI/Program.cs @@ -38,6 +38,12 @@ builder.Services.ConfigureApplicationCookie(o => { ctx.Response.StatusCode = 403; } return Task.CompletedTask; + }, + OnRedirectToReturnUrl = (ctx) => { + if (ctx.Request.Path.StartsWithSegments("/api") && ctx.Response.StatusCode == 200) { + ctx.Response.StatusCode = 418; + } + return Task.CompletedTask; } }; }); diff --git a/GrossesMitaines/grosses-mitaines-ui/src/pages/Inventaire.js b/GrossesMitaines/grosses-mitaines-ui/src/pages/Inventaire.js index 92b5ab1..f5ef952 100644 --- a/GrossesMitaines/grosses-mitaines-ui/src/pages/Inventaire.js +++ b/GrossesMitaines/grosses-mitaines-ui/src/pages/Inventaire.js @@ -22,6 +22,7 @@ const Inventaire = () => { const handleAddItem = async (morceau) => { const response = await fetch(`https://localhost:7292/api/Product`, { method: 'POST', + credentials: 'include', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' @@ -42,7 +43,11 @@ const Inventaire = () => { const handleDeleteItem = async (id) => { - const response = await fetch(`https://localhost:7292/api/Product?id=${id}`, { method: 'DELETE', mode: 'cors' }); + const response = await fetch(`https://localhost:7292/api/Product?id=${id}`, { + method: 'DELETE', + mode: 'cors', + credentials: 'include' + }); const deletedId = await response.json(); @@ -58,6 +63,7 @@ const Inventaire = () => { const handleModifyItem = async (morceau) => { const response = await fetch(`https://localhost:7292/api/Product`, { method: 'PATCH', + credentials: 'include', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' diff --git a/GrossesMitaines/grosses-mitaines-ui/src/pages/Login.js b/GrossesMitaines/grosses-mitaines-ui/src/pages/Login.js index 40dd38c..b9e1bec 100644 --- a/GrossesMitaines/grosses-mitaines-ui/src/pages/Login.js +++ b/GrossesMitaines/grosses-mitaines-ui/src/pages/Login.js @@ -2,7 +2,7 @@ import { useState } from "react"; import { Button } from "react-bootstrap"; const Login = () => { - + const [rememberme, setPersistence] = useState(false); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [returnmess, returnMessage] = useState(""); @@ -10,7 +10,7 @@ const Login = () => { const handleLogin = async (e) => { e.preventDefault(); - const response = await fetch(`https://localhost:7292/api/Login?rememberMe=true`, { + const response = await fetch(`https://localhost:7292/api/Login?rememberMe=${rememberme}`, { method: 'POST', credentials: 'include', headers: { @@ -35,7 +35,7 @@ const Login = () => { console.log(await confirm.json()) returnMessage("WOOHOO!"); } - else returnMessage("Le nom d'Utilisateur ou le mot de passe est incorrect."); + else returnMessage("L'adresse courriel ou le mot de passe est incorrect."); } else returnMessage("Erreur d'API.") }