affichage des erreurs
This commit is contained in:
parent
db504120f9
commit
cfbf0d7471
@ -49,10 +49,29 @@
|
||||
<body class="text-center">
|
||||
|
||||
<main class="form-signin">
|
||||
<div class="alert alert-danger alert-dismissible hidden" id="alertPassword" role="alert">
|
||||
<div>Utilisateur inexistant ou mauvais mot de passe</div>
|
||||
<button type="button" id="closeAlertPassword" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
<div class="alert alert-danger alert-dismissible hidden" id="alertUsername" role="alert">
|
||||
<div>Utilisateur inexistant</div>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="alert alert-danger alert-dismissible hidden" id="alertDisable" role="alert">
|
||||
<div>Compte désactivé</div>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="alert alert-danger alert-dismissible hidden" id="alertPassword" role="alert">
|
||||
<div>Mot de passe incorrect</div>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-danger alert-dismissible hidden" id="alertToken" role="alert">
|
||||
<div>Token expiré</div>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-danger alert-dismissible hidden" id="alertUnknown" role="alert">
|
||||
<div>Mot de passe incorrect</div>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
|
||||
<form id="signin">
|
||||
<img class="mb-4" src="css/bootstrap-logo.svg" alt="" width="72" height="57">
|
||||
|
@ -13,13 +13,39 @@ document.getElementById("signin").addEventListener("submit", function(evt){
|
||||
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");
|
||||
|
||||
switch (error.response.status){
|
||||
case 406:
|
||||
id = "alertPassword";
|
||||
break;
|
||||
case 404:
|
||||
id = "alertUsername";
|
||||
break;
|
||||
case 403:
|
||||
id = "alertDisable";
|
||||
break;
|
||||
case 410:
|
||||
id = "alertToken";
|
||||
break;
|
||||
default:
|
||||
id = "alertUnknown";
|
||||
break;
|
||||
}
|
||||
|
||||
document.getElementById(id).classList.remove("hidden");
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById("closeAlertPassword").addEventListener("click", function(){
|
||||
document.getElementById("alertPassword").classList.add("hidden");
|
||||
var btnclose = document.getElementsByClassName("btn-close");
|
||||
for (var i = 0; i<btnclose.length; i++){
|
||||
btnclose[i].addEventListener("click", function(){
|
||||
var alertt = document.getElementsByClassName("alert");
|
||||
for (var j=0; j<alertt.length; j++){
|
||||
if(!alertt[j].classList.contains("hidden")){
|
||||
alertt[j].classList.add("hidden");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user