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,44 @@
|
||||
const changepasswordform = document.querySelector(".changepasswordform");
|
||||
const cancelchangepassword = document.querySelector("#cancelchangepassword");
|
||||
const changepasswordformbody = document.querySelector(
|
||||
".changepasswordformbody",
|
||||
);
|
||||
const changepasswordnewpassword = document.querySelector(
|
||||
"#changepasswordnewpassword",
|
||||
);
|
||||
|
||||
let changepassuserid = "";
|
||||
|
||||
const change_password = (userid) => {
|
||||
changepasswordform.classList.add("active");
|
||||
changepassuserid = userid;
|
||||
};
|
||||
|
||||
cancelchangepassword.addEventListener("click", (e) => {
|
||||
e.preventDefault();
|
||||
changepasswordform.classList.remove("active");
|
||||
});
|
||||
|
||||
changepasswordformbody.addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
const hashedpassword = await hashPassword(changepasswordnewpassword.value);
|
||||
const status = await fetch(routes.change_password_url(), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: `{"token":"${localStorage.getItem("token")}","id":"${changepassuserid}","new_password":"${hashedpassword}"}`,
|
||||
})
|
||||
.then((data) => data.json())
|
||||
.then((jsondata) => jsondata)
|
||||
.catch((error) => {
|
||||
notification(`Ошибка на сервере: ${error}`, "error");
|
||||
});
|
||||
if (!status.error) {
|
||||
notification("Пароль успешно изменен", "success");
|
||||
changepasswordform.classList.remove("active");
|
||||
changepasswordnewpassword.value = "";
|
||||
} else {
|
||||
notification(status.error, "error");
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user