Fix logout to reset auth forms to login
This commit is contained in:
1
SPEC.md
1
SPEC.md
@@ -10,6 +10,7 @@ Help a small Discord group (4–8 players) pick a co-op game via phased flow:
|
||||
- Single shared instance
|
||||
- Username/password login (cookie auth)
|
||||
- Admins flagged via admin key at registration
|
||||
- Logout returns to the login form and clears all auth form fields
|
||||
- Per-user phase tracking; admins can move themselves backward, everyone can move forward (subject to admin “results open” toggle and Suggest→Vote requiring at least one own suggestion)
|
||||
|
||||
## Suggest Phase
|
||||
|
||||
@@ -188,5 +188,5 @@ Registriere dich erneut mit dem korrekten Schlüssel vom Host ‒ oder lasse das
|
||||
|
||||
- Vorschläge, Stimmen und Phasenstatus werden in einer gemeinsamen **SQLite-Datenbank** gespeichert.
|
||||
- Passwörtwer werden mit einer SHA256 Verschlüsselung gespeichert.
|
||||
- Beim Abmelden wird dein Authentifizierungs-Cookie gelöscht.
|
||||
- Beim Abmelden wird dein Authentifizierungs-Cookie gelöscht und die Eingaben in Login/Registrierung werden zurückgesetzt.
|
||||
- Wenn ein Admin dein Spielerkonto löscht, werden auch deine Vorschläge und Stimmen entfernt.
|
||||
|
||||
@@ -192,5 +192,5 @@ Register again using the correct key from the host ‒ or leave it blank to crea
|
||||
|
||||
- Suggestions, votes, and phase states are stored in a shared **SQLite database**.
|
||||
- Passwords are stored with a SHA256 encryption.
|
||||
- Logging out clears your authentication cookie.
|
||||
- Logging out clears your authentication cookie and resets login/register form inputs.
|
||||
- If an admin deletes your player account, your suggestions and votes are removed as well.
|
||||
|
||||
@@ -141,22 +141,17 @@ function setupLogoutHandler() {
|
||||
|
||||
logoutBtn.addEventListener("click", async (e) => {
|
||||
e.preventDefault();
|
||||
const lastUser = state.me?.username;
|
||||
try {
|
||||
await api.logout();
|
||||
} catch (err) {
|
||||
toast(err.message, true);
|
||||
}
|
||||
document.querySelectorAll(".auth-form").forEach((form) => form.reset());
|
||||
setAuthMode("login");
|
||||
setSavedUsername("");
|
||||
clearUserState();
|
||||
state.isAuthenticated = false;
|
||||
setAuthUI(false);
|
||||
if (lastUser) {
|
||||
setSavedUsername(lastUser);
|
||||
const loginUser = $("login-username");
|
||||
if (loginUser) loginUser.value = lastUser;
|
||||
const loginPass = $("login-password");
|
||||
if (loginPass) loginPass.value = "";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user