authentification

This commit is contained in:
2022-07-20 23:34:56 +02:00
parent 1eb459c44b
commit db504120f9
3 changed files with 26 additions and 6 deletions

View File

@@ -6,9 +6,20 @@ instance.get("token", { withCredentials: true})
document.getElementById("signin").addEventListener("submit", function(evt){
evt.preventDefault();
var email = document.getElementById("floatingEmail");
var pseudo = document.getElementById("floatingPseudo");
var password = document.getElementById("floatingPassword");
if((password.value.length > 0) || (email.value.length > 0)){
console.log("request");
if((password.value.length > 0) || (pseudo.value.length > 0)){
console.log(pseudo.value);
instance.get("token", { auth : {username: pseudo.value, password: password.value}, withCredentials: true})
.then(function(response) { console.log(response) })
.catch(function(error){
if(error.response.status == 404){
document.getElementById("alertPassword").classList.remove("hidden");
}
});
}
})
});
document.getElementById("closeAlertPassword").addEventListener("click", function(){
document.getElementById("alertPassword").classList.add("hidden");
});