!!!
This commit is contained in:
		| @@ -61,4 +61,3 @@ public class LoginController : Controller { | |||||||
|  |  | ||||||
|     #endregion |     #endregion | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -38,6 +38,12 @@ builder.Services.ConfigureApplicationCookie(o => { | |||||||
|                 ctx.Response.StatusCode = 403; |                 ctx.Response.StatusCode = 403; | ||||||
|             } |             } | ||||||
|             return Task.CompletedTask; |             return Task.CompletedTask; | ||||||
|  |         }, | ||||||
|  |         OnRedirectToReturnUrl = (ctx) => { | ||||||
|  |             if (ctx.Request.Path.StartsWithSegments("/api") && ctx.Response.StatusCode == 200) { | ||||||
|  |                 ctx.Response.StatusCode = 418; | ||||||
|  |             } | ||||||
|  |             return Task.CompletedTask; | ||||||
|         } |         } | ||||||
|     }; |     }; | ||||||
| }); | }); | ||||||
|   | |||||||
| @@ -22,6 +22,7 @@ const Inventaire = () => { | |||||||
|     const handleAddItem = async (morceau) => { |     const handleAddItem = async (morceau) => { | ||||||
|         const response = await fetch(`https://localhost:7292/api/Product`, { |         const response = await fetch(`https://localhost:7292/api/Product`, { | ||||||
|             method: 'POST', |             method: 'POST', | ||||||
|  |             credentials: 'include', | ||||||
|             headers: { |             headers: { | ||||||
|                 'Accept': 'application/json', |                 'Accept': 'application/json', | ||||||
|                 'Content-Type': 'application/json' |                 'Content-Type': 'application/json' | ||||||
| @@ -42,7 +43,11 @@ const Inventaire = () => { | |||||||
|  |  | ||||||
|     const handleDeleteItem = async (id) => { |     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(); |         const deletedId = await response.json(); | ||||||
|  |  | ||||||
| @@ -58,6 +63,7 @@ const Inventaire = () => { | |||||||
|     const handleModifyItem = async (morceau) => { |     const handleModifyItem = async (morceau) => { | ||||||
|         const response = await fetch(`https://localhost:7292/api/Product`, { |         const response = await fetch(`https://localhost:7292/api/Product`, { | ||||||
|             method: 'PATCH', |             method: 'PATCH', | ||||||
|  |             credentials: 'include', | ||||||
|             headers: { |             headers: { | ||||||
|                 'Accept': 'application/json', |                 'Accept': 'application/json', | ||||||
|                 'Content-Type': 'application/json' |                 'Content-Type': 'application/json' | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ import { useState } from "react"; | |||||||
| import { Button } from "react-bootstrap"; | import { Button } from "react-bootstrap"; | ||||||
|  |  | ||||||
| const Login = () => { | const Login = () => { | ||||||
|  |     const [rememberme, setPersistence] = useState(false); | ||||||
|     const [email, setEmail] = useState(""); |     const [email, setEmail] = useState(""); | ||||||
|     const [password, setPassword] = useState(""); |     const [password, setPassword] = useState(""); | ||||||
|     const [returnmess, returnMessage] = useState(""); |     const [returnmess, returnMessage] = useState(""); | ||||||
| @@ -10,7 +10,7 @@ const Login = () => { | |||||||
|     const handleLogin = async (e) => { |     const handleLogin = async (e) => { | ||||||
|         e.preventDefault(); |         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', |             method: 'POST', | ||||||
|             credentials: 'include', |             credentials: 'include', | ||||||
|             headers: { |             headers: { | ||||||
| @@ -35,7 +35,7 @@ const Login = () => { | |||||||
|                 console.log(await confirm.json()) |                 console.log(await confirm.json()) | ||||||
|                 returnMessage("WOOHOO!"); |                 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.")            |         else returnMessage("Erreur d'API.")            | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user