affichage des erreurs
This commit is contained in:
parent
db504120f9
commit
cfbf0d7471
@ -49,11 +49,30 @@
|
|||||||
<body class="text-center">
|
<body class="text-center">
|
||||||
|
|
||||||
<main class="form-signin">
|
<main class="form-signin">
|
||||||
|
<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 class="alert alert-danger alert-dismissible hidden" id="alertPassword" role="alert">
|
||||||
<div>Utilisateur inexistant ou mauvais mot de passe</div>
|
<div>Mot de passe incorrect</div>
|
||||||
<button type="button" id="closeAlertPassword" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
</div>
|
</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">
|
<form id="signin">
|
||||||
<img class="mb-4" src="css/bootstrap-logo.svg" alt="" width="72" height="57">
|
<img class="mb-4" src="css/bootstrap-logo.svg" alt="" width="72" height="57">
|
||||||
<h1 class="h3 mb-3 fw-normal">Please sign in</h1>
|
<h1 class="h3 mb-3 fw-normal">Please sign in</h1>
|
||||||
|
@ -13,13 +13,39 @@ document.getElementById("signin").addEventListener("submit", function(evt){
|
|||||||
instance.get("token", { auth : {username: pseudo.value, password: password.value}, withCredentials: true})
|
instance.get("token", { auth : {username: pseudo.value, password: password.value}, withCredentials: true})
|
||||||
.then(function(response) { console.log(response) })
|
.then(function(response) { console.log(response) })
|
||||||
.catch(function(error){
|
.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(){
|
var btnclose = document.getElementsByClassName("btn-close");
|
||||||
document.getElementById("alertPassword").classList.add("hidden");
|
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