check roles users

This commit is contained in:
Valentin CZERYBA 2023-10-20 23:41:13 +02:00
parent 326b21a65c
commit 03ec97003e

View File

@ -9,7 +9,13 @@ document.getElementById("signin").addEventListener("submit", function(evt){
authData = {username: pseudo.value, password: password.value} authData = {username: pseudo.value, password: password.value}
instance.post("token", {username: pseudo.value, password: password.value}, {headers: {'Accept': 'application/json', 'Content-Type': 'application/x-www-form-urlencoded' }}) instance.post("token", {username: pseudo.value, password: password.value}, {headers: {'Accept': 'application/json', 'Content-Type': 'application/x-www-form-urlencoded' }})
.then(function(response) { .then(function(response) {
location.href="html/users.html"; }) if(response.data["roles"] == "Admin"){
location.href="html/users.html";
}
else {
instance.delete("token")
}
})
.catch(function(error){ .catch(function(error){
switch (error.response.status){ switch (error.response.status){