added ability to change password
This commit is contained in:
		@@ -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;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user