diff --git a/css/form.css b/css/form.css index 005f653..522ac76 100644 --- a/css/form.css +++ b/css/form.css @@ -23,7 +23,8 @@ input, label, legend { input { border: solid white 1px; - width: min-content; + min-width: fit-content; + width: 100%; } input:focus { @@ -38,7 +39,8 @@ select { border: solid white 1px; background-color: black; color: white; - width: min-content; + min-width: fit-content; + width: 100%; } select:disabled { diff --git a/login.html b/login.html index 1607015..8c8b989 100644 --- a/login.html +++ b/login.html @@ -11,7 +11,7 @@
-
+
Proxmox VE Login
@@ -19,6 +19,8 @@ + +
diff --git a/scripts/login.js b/scripts/login.js index a4d6dcb..aacec0c 100644 --- a/scripts/login.js +++ b/scripts/login.js @@ -1,11 +1,16 @@ -import {requestTicket, setTicket, ResponseError, NetworkError, goToPage, deleteAllCookies} from "./utils.js"; +import {requestTicket, setTicket, ResponseError, NetworkError, goToPage, deleteAllCookies, requestPVE} from "./utils.js"; window.addEventListener("DOMContentLoaded", init); -function init (){ +async function init (){ deleteAllCookies(); let formSubmitButton = document.querySelector("#submit"); let status = document.querySelector("#status"); + let realms = await requestPVE("/access/domains", "GET"); + let realmSelect = document.querySelector("#realm"); + realms.data.forEach((element) => { + realmSelect.add(new Option(element.comment, element.realm)); + }); formSubmitButton.addEventListener("click", async (e) => { status.innerText = ""; status.style.color = "#000000"; @@ -14,7 +19,7 @@ function init (){ let formData = new FormData(form); try { status.innerText = "Authenticating..."; - let ticket = await requestTicket(formData.get("username"), formData.get("password")); + let ticket = await requestTicket(formData.get("username"), formData.get("password"), formData.get("realm")); setTicket(ticket.data.ticket, ticket.data.CSRFPreventionToken, formData.get("username")); status.innerText = "Authentication successful!" status.style.color = "#00ff00"; diff --git a/scripts/utils.js b/scripts/utils.js index e501822..3622abf 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -81,9 +81,8 @@ export function getCookie(cname) { return ""; } -export async function requestTicket (username, password) { - let response = await requestPVE("/access/ticket", "POST", {username: `${username}@ldap`, password: password}, false); - +export async function requestTicket (username, password, realm) { + let response = await requestPVE("/access/ticket", "POST", {username: `${username}@${realm}`, password: password}, false); return response; } @@ -144,6 +143,10 @@ async function request (url, content) { throw new NetworkError(error); }); + if(!response.ok){ + throw new ResponseError(response); + } + let data = await response.json(); data.status = response.status; return data;