mirror of
https://github.com/PretendoNetwork/website.git
synced 2025-04-02 11:11:50 -04:00
30 lines
899 B
JavaScript
30 lines
899 B
JavaScript
const passwordInput = document.querySelector('#password');
|
|
const passwordConfirmInput = document.querySelector('#password_confirm');
|
|
const tokenInput = document.querySelector('#token');
|
|
|
|
document.querySelector('form').addEventListener('submit', function (event) {
|
|
event.preventDefault();
|
|
|
|
fetch('https://api.pretendo.cc/v1/reset-password', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
password: passwordInput.value,
|
|
password_confirm: passwordConfirmInput.value,
|
|
token: tokenInput.value
|
|
})
|
|
})
|
|
.then(response => response.json())
|
|
.then(body => {
|
|
if (body.error) {
|
|
alert(`Error: ${body.error}. TODO: red error message thing`);
|
|
} else {
|
|
alert('Password reset. TODO: reword this and green success');
|
|
window.location.assign('/account/login');
|
|
}
|
|
})
|
|
.catch(console.log);
|
|
});
|