Add QR Code for Keypasses
This commit is contained in:
@@ -204,6 +204,30 @@ document.getElementById("logout-btn").addEventListener("click", () => {
|
||||
|
||||
// ── Init ──────────────────────────────────────────────────────────────────────
|
||||
(function init() {
|
||||
// Auto-login when the URL contains ?k=CODE (e.g. scanned from a QR code)
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const k = params.get("k");
|
||||
if (k) {
|
||||
// Remove the code from the URL immediately so it doesn't linger in history
|
||||
history.replaceState(null, "", window.location.pathname);
|
||||
fetch("/api/auth/keypass", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ code: k.toUpperCase() }),
|
||||
})
|
||||
.then(res => res.ok ? res.json() : Promise.reject())
|
||||
.then(data => {
|
||||
saveToken(data.token);
|
||||
showGatesView();
|
||||
loadGates();
|
||||
})
|
||||
.catch(() => {
|
||||
clearToken();
|
||||
showLogin();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const t = getToken();
|
||||
if (tokenValid(t)) {
|
||||
showGatesView();
|
||||
|
||||
Reference in New Issue
Block a user