Prefill login username from cookie
This commit is contained in:
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user