document.addEventListener('DOMContentLoaded', async function() {
    console.log("here i am")
});

async function authenticateLogin() {
    var username = document.getElementById('login_username').value;
    var password = document.getElementById('login_password').value;

    const response = await fetch('/login/authenticate', {
        method: 'POST',
        headers:{
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({
            user_username: username,
            user_password: password
        }),
    });

    data = await response.json()
    console.log(data)
    if (data.error){
        UIkit.notification({
            message: data.message,
            status: "danger",
            pos: 'bottom-right',
            timeout: 5000
        });
    } else if (!data.error) {
        window.location.href = '/';
    }
}