29 lines
1.2 KiB
JavaScript
29 lines
1.2 KiB
JavaScript
|
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, month, parseInt(day), parseInt(year))
|
||
|
if (response.status !== 200) {
|
||
|
const error = document.getElementsByClassName('error')[1]
|
||
|
error.innerHTML = response.msg
|
||
|
} else {
|
||
|
location.href = '/home'
|
||
|
}
|
||
|
}
|