update added jwt tokens
This commit is contained in:
1 parent
a5e28c5533
commit
b0064a9b81
25 files changed
+2004
-31
No files matched your search
@@ -0,0 +1,47 @@
|
||||
const userstablebody = document.querySelector("#alluserstablebody");
|
||||
const confirmform = document.querySelector(".confirmform");
|
||||
const confirmformcancel = document.querySelector("#no");
|
||||
const confirmformok = document.querySelector("#yes");
|
||||
|
||||
let useridtodelete = "";
|
||||
|
||||
userstablebody.addEventListener("click", (e) => {
|
||||
if (e.target.classList.contains("deleteuser")) {
|
||||
useridtodelete = e.target.id;
|
||||
confirmform.classList.add("active");
|
||||
}
|
||||
if (e.target.classList.contains("changepassword")) {
|
||||
change_password(e.target.id);
|
||||
}
|
||||
if (e.target.classList.contains("changeuser")) {
|
||||
change_user_data(e.target.id);
|
||||
}
|
||||
});
|
||||
|
||||
confirmformcancel.addEventListener("click", () => {
|
||||
useridtodelete = "";
|
||||
confirmform.classList.remove("active");
|
||||
});
|
||||
|
||||
confirmformok.addEventListener("click", async () => {
|
||||
const status = await fetch(routes.deluser(), {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: `{"token":"${localStorage.getItem("token")}","id":"${useridtodelete}"}`,
|
||||
})
|
||||
.then((data) => data.json())
|
||||
.then((jsondata) => jsondata)
|
||||
.catch((error) => {
|
||||
notification(`Ошибка на сервере: ${error}`, "error");
|
||||
});
|
||||
if (status.success) {
|
||||
confirmform.classList.remove("active");
|
||||
await get_all_users();
|
||||
notification("Пользователь успешно удален", "success");
|
||||
} else {
|
||||
notification("Can't delete user", "error");
|
||||
confirmform.classList.remove("active");
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user