xssbook/public/js/login.js
2023-01-28 02:51:34 -05:00

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