-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnexion.js
30 lines (28 loc) · 966 Bytes
/
connexion.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
document.querySelector("#btnConnexion").addEventListener("click",async()=>{
const email = document.getElementById("email").value;
const password = document.getElementById("password").value;
if(email!=null&&password!=null)
{
const compte= {email, password};
const response= await fetch("/projet1/api/connexion",{
method:"POST",
headers:{
"Content-Type":"application"
},
body:JSON.stringify(compte),
} );
const responseData= await response.json();
if(responseData.connexion=="Connexion réussie")
{
sessionStorage.setItem('email',email);
sessionStorage.setItem('username',responseData.username);
window.location.href='/projet1/pageUtilisateur.html';
}
if(responseData.connexion=="faux")
{
alert("Email ou mot de passe incorrect");
}
}
else{
}
});