57 lines
1.4 KiB
HTML
57 lines
1.4 KiB
HTML
<div>
|
|
<h3>Password Change</h3>
|
|
<table>
|
|
<tr>
|
|
<td>New Password:</td>
|
|
<td>
|
|
<input type="password" id="newPassword" placeholder="***" required />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Confirm Password:</td>
|
|
<td>
|
|
<input
|
|
type="password"
|
|
id="confirmPassword"
|
|
placeholder="***"
|
|
required
|
|
/>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<button id="confirmPasswordChange">Confirm Change</button>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<script>
|
|
document
|
|
.getElementById("confirmPasswordChange")
|
|
.addEventListener("click", function () {
|
|
const newPassword = document.getElementById("newPassword").value;
|
|
const confirmPassword =
|
|
document.getElementById("confirmPassword").value;
|
|
|
|
if (newPassword !== confirmPassword) {
|
|
displayFail("Passwords do not match. Please try again.");
|
|
return;
|
|
}
|
|
|
|
fetch("/web-api/change_password", {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({ new_password: newPassword }),
|
|
}).then((response) => {
|
|
if (!response.ok) {
|
|
displayHttpStatusAndPayload(response);
|
|
} else {
|
|
displaySuccess("Password changed successfully.");
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
</div>
|