react-version #1
@ -61,4 +61,3 @@ public class LoginController : Controller {
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
@ -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'
|
||||
|
@ -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.")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user