2023-01-26 22:29:16 +00:00
|
|
|
async function onlogin() {
|
|
|
|
const email = document.getElementById('email').value
|
|
|
|
const password = document.getElementById('pass').value
|
|
|
|
const response = await login(email, password)
|
|
|
|
if (response.status !== 200) {
|
|
|
|
const error = document.getElementsByClassName('error')[0]
|
|
|
|
error.innerHTML = response.msg
|
|
|
|
} else {
|
|
|
|
location.href = '/home'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function onregister() {
|
|
|
|
const first = document.getElementById('firstname').value
|
|
|
|
const last = document.getElementById('lastname').value
|
|
|
|
const email = document.getElementById('newemail').value
|
|
|
|
const pass = document.getElementById('newpass').value
|
|
|
|
const month = document.getElementById('month').value
|
|
|
|
const day = document.getElementById('day').value
|
|
|
|
const year = document.getElementById('year').value
|
|
|
|
const gender = document.querySelector('input[name="gender"]:checked').value
|
|
|
|
const response = await register(first, last, email, pass, gender, parseInt(day), parseInt(month), parseInt(year))
|
2023-01-28 07:51:34 +00:00
|
|
|
if (response.status !== 201) {
|
2023-01-26 22:29:16 +00:00
|
|
|
const error = document.getElementsByClassName('error')[1]
|
|
|
|
error.innerHTML = response.msg
|
|
|
|
} else {
|
|
|
|
location.href = '/home'
|
|
|
|
}
|
|
|
|
}
|