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 {
|
2022-12-12 23:00:32 +00:00
|
|
|
let ticket = await requestTicket(formData.get("username"), formData.get("password"));
|
2022-12-12 22:57:43 +00:00
|
|
|
await setTicket(ticket);
|
|
|
|
window.location.href = "index.html";
|
|
|
|
}
|
|
|
|
catch (error) {
|
|
|
|
console.log(error);
|
|
|
|
}
|
|
|
|
}
|