ProxmoxAAS-Dashboard/login.js

21 lines
591 B
JavaScript
Raw Normal View History

2022-12-12 22:57:43 +00:00
import {requestTicket, setTicket} from "./utils.js";
window.addEventListener("DOMContentLoaded", init);
function init (){
let formSubmitButton = document.querySelector("#submit");
formSubmitButton.addEventListener("click", loginFormSubmitHandler);
}
async function loginFormSubmitHandler () {
let form = document.querySelector("form");
let formData = new FormData(form);
try {
let ticket = await requestTicket(formData.username, formData.password);
await setTicket(ticket);
window.location.href = "index.html";
}
catch (error) {
console.log(error);
}
}