ProxmoxAAS-Dashboard/scripts/login.js

20 lines
597 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");
2022-12-12 23:11:52 +00:00
formSubmitButton.addEventListener("click", async (e) => {
e.preventDefault();
let form = document.querySelector("form");
let formData = new FormData(form);
try {
let ticket = await requestTicket(formData.get("username"), formData.get("password"));
2022-12-12 23:13:43 +00:00
await setTicket(ticket.data.ticket);
2022-12-12 23:11:52 +00:00
window.location.href = "index.html";
}
catch (error) {
console.log(error);
}
});
2022-12-12 22:57:43 +00:00
}