login and register logic

This commit is contained in:
biglyderv 2025-02-25 19:47:28 -05:00
parent a2f8452eec
commit 8d0c02e27e
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5
15 changed files with 496 additions and 106 deletions

30
public/index.js Normal file
View file

@ -0,0 +1,30 @@
async function formClick(ev) {
ev.preventDefault();
let { target } = ev;
let fData = new FormData(target);
let file = target.querySelector('input[type=file]');
if (file)
file.value = null;
let fetched = await fetch(target.action, {
'method': 'POST',
'body': fData
});
let json = await fetched.json();
target.querySelector('.form-message').textContent = json.message;
if (json.redirect && json.success) {
setTimeout(function () {
window.location.href = json.redirect;
}, 2000);
}
}
window.onload = function () {
document.addEventListener('submit', formClick);
}