This repository has been archived on 2024-09-22. You can view files and clone it, but cannot push or open issues or pull requests.
self-service-ui/web/index.html

66 lines
2.0 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
<html>
<head>
<title>Password change</title>
<script type="text/javascript">
window.onload = () => {
const myform = document.getElementById('pwchange');
myform.addEventListener('submit', e => {
e.preventDefault();
const username = document.getElementById('username');
const bind_pass = document.getElementById('bind_pass');
const password = document.getElementById('password');
const payload = {
bind_pw: bind_pass.value,
userPassword: password.value
};
const response = fetch('/api/users/uid=' + username.value + '/updatePassword', {
method: 'POST',
cache: 'no-cache',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
console.log(response)
response.then(r => r.json()).then(answer => {
if (response.status === 204) {
alert('Password was updated');
}
})
.catch(e => {
console.log(e);
if (response.status === 401) {
alert('Invalid current password supplied');
} else {
alert('Error updating password: ' + response.status + ' ' + response.statusText);
}
})
})
}
</script>
</head>
<body>
<h1>finallycoffee.eu password self-service</h1>
<table>
<form id="pwchange">
<tr>
<td>Username</td>
<td><input type="text" name="username" id="username" /></td>
</tr>
<tr>
<td>Current Password</td>
<td><input type="password" name="old_password" id="bind_pass" /></td>
</tr>
<tr>
<td>New Password</td>
<td><input type="password" name="password" id="password" /></td>
</tr>
<tr>
<td><input type="submit" value="Change password" /></td>
</tr>
</form>
</table>
</body>
</html>