Prefill login username from cookie

This commit is contained in:
2026-01-29 01:34:03 +01:00
parent 307fd1abda
commit 35bccb6dcf

View File

@@ -34,9 +34,20 @@ function setAuthUI(isAuthed) {
if (!isAuthed) {
const adminCard = $("admin-card");
if (adminCard) adminCard.classList.add("hidden");
const loginUser = $("login-username");
const cachedUser = getCookie("player_username");
if (loginUser && cachedUser) loginUser.value = cachedUser;
}
}
function getCookie(name) {
const cookie = document.cookie
?.split(";")
.map(c => c.trim())
.find(c => c.startsWith(name + "="));
return cookie ? decodeURIComponent(cookie.split("=").slice(1).join("=")) : null;
}
function setAuthMode(mode) {
state.authMode = mode;
document.querySelectorAll(".auth-form").forEach(form => {