PURT DAT KOOKEE DAOWN, NAOW!!!
This commit is contained in:
parent
bbff60ca54
commit
f0fc91383a
@ -10,7 +10,6 @@ using System.Net;
|
||||
|
||||
var MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddCors(options => {
|
||||
options.AddPolicy(name: MyAllowSpecificOrigins,
|
||||
@ -18,7 +17,8 @@ builder.Services.AddCors(options => {
|
||||
policy.WithOrigins("http://localhost:3000",
|
||||
"http://localhost:3001")
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader();
|
||||
.AllowAnyHeader()
|
||||
.AllowCredentials();
|
||||
});
|
||||
});
|
||||
|
||||
@ -57,9 +57,6 @@ builder.Services.AddDbContextFactory<InventoryContext>(options => { options.UseS
|
||||
builder.Services.AddSingleton<DatabaseCacheService>();
|
||||
builder.Services.BuildServiceProvider().GetRequiredService<DatabaseCacheService>();
|
||||
|
||||
|
||||
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
|
@ -5,28 +5,49 @@ const Login = () => {
|
||||
|
||||
const [username, setUsername] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [kookees, setCookies] = useState("");
|
||||
const [returnmess, returnMessage] = useState("");
|
||||
|
||||
const handleLogin = async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const response = await fetch(`https://localhost:7292/api/Login?rememberMe=true`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
'Accept': 'text/json',
|
||||
'Content-Type': 'text/json'
|
||||
},
|
||||
body: JSON.stringify({ username, password })
|
||||
})
|
||||
});
|
||||
// Partie de display d'erreur ou de redirection (faudrait checker pour se faire un state de connexion avec un cookie pour react).
|
||||
|
||||
if (response.status === 200) {
|
||||
var rep = await response.json();
|
||||
if (rep.succeeded === true) {
|
||||
const confirm = await fetch(`https://localhost:7292/api/Login`, {
|
||||
method: 'GET',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Accept': 'text/json',
|
||||
'Content-Type': 'text/json'
|
||||
}
|
||||
});
|
||||
console.log(await confirm.json())
|
||||
returnMessage("WOOHOO!");
|
||||
}
|
||||
else returnMessage("Le nom d'Utilisateur ou le mot de passe est incorrect.");
|
||||
}
|
||||
else returnMessage("Erreur d'API.")
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="inventaire-form-container">
|
||||
<h1>{kookees}</h1>
|
||||
|
||||
<form className="form-horizontal" onSubmit={handleLogin}>
|
||||
<h4 className="text-center">Connexion</h4>
|
||||
<div>
|
||||
<h5>{returnmess}</h5>
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label>Nom Utilisateur: </label>
|
||||
<input className="form-control form-input" type='text'
|
||||
|
Loading…
Reference in New Issue
Block a user