added ability to change password

This commit is contained in:
2025-01-31 17:53:27 +03:00
parent f5a89a59c7
commit 100b060aa7
5 changed files with 58 additions and 2 deletions

View File

@@ -38,10 +38,34 @@ const uploadCape = async (event) => {
window.location = window.location.href+'?eraseCache=true';
}
const changePassword = async (event) => {
event.preventDefault();
const oldPassword = document.getElementById("oldPassword").value
const newPassword = document.getElementById("newPassword").value
if (oldPassword == newPassword) {
alert("You cannod change your password to the same!")
return;
}
await fetch(`/api/changePassword`, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
oldPassword,
newPassword
})
});
alert("Password has been changed!");
}
window.onload = async function() {
document.getElementById("skinForm").addEventListener("submit", uploadSkin)
document.getElementById("passwordChangeForm").addEventListener("submit", changePassword);
if (document.getElementById("cape")) {
document.getElementById("cape").addEventListener("click", () => { set_cape_type("cape") }, false);
document.getElementById("cape").checked = true;