fix: Sign out + login flow + cache bust for i18n
CI / lint (push) Failing after 20s
CI / test (push) Has been skipped
CI / build (push) Has been skipped
CI / e2e (push) Has been skipped
CI / security (push) Failing after 11s

- auth.js: window.handleLogout at module top level (was inside
  renderUserMenu, not always called). Fixes settings dropdown
  'Sign out' onclick='handleLogout()' doing nothing.
- auth.js: add missing imports (loadVaults, loadTags from sidebar.js)
  and dynamic import for IndexUpdateManager (circular dep avoidance).
  Fixes 'loadVaults is not defined' error on login.
- sw.js: CACHE_VERSION v4→v5 to bust stale Service Worker cache
  that was serving old viewer.js without data-i18n attributes,
  causing dashboard tabs to stay French despite English profile.

To apply: rebuild container + unregister SW in DevTools + reload.
This commit is contained in:
2026-06-21 11:37:51 -04:00
parent 6d4a45797e
commit bea23820ab
2 changed files with 12 additions and 5 deletions
+11 -4
View File
@@ -4,6 +4,15 @@ import { safeCreateIcons } from './utils.js';
import { showToast, closeHeaderMenu } from './ui.js';
import { t, getLocale } from './i18n.js';
import { showWelcome } from './viewer.js';
import { loadVaults, loadTags } from './sidebar.js';
// ── Global logout handler for header dropdown onclick ────────────────────
// Defined at module top level so it's always available, even if
// renderUserMenu() hasn't been called yet.
// Uses a getter to lazy-resolve AuthManager (defined later in this module).
window.handleLogout = () => {
AuthManager.logout();
};
// ---------------------------------------------------------------------------
// API helpers
@@ -201,9 +210,6 @@ const AuthManager = {
const logoutBtn = document.getElementById("logout-btn");
if (logoutBtn) logoutBtn.addEventListener("click", () => AuthManager.logout());
// Also wire up the header dropdown "Sign out" (onclick="handleLogout()")
window.handleLogout = () => AuthManager.logout();
const adminRow = document.getElementById("admin-menu-row");
if (adminRow) {
if (user.role === "admin") {
@@ -313,7 +319,8 @@ function initLoginForm() {
// Load app data after successful login
try {
await Promise.all([loadVaults(), loadTags()]);
// Start SSE sync now that auth cookie is set
// Start SSE sync now that auth cookie is set (dynamic import to avoid circular dep)
const { IndexUpdateManager } = await import('./sync.js');
IndexUpdateManager.connect();
// Show dashboard
showWelcome();
+1 -1
View File
@@ -1,6 +1,6 @@
/* ObsiGate Service Worker - PWA v2 with IndexedDB offline support */
const CACHE_VERSION = 'obsigate-v4-pwa';
const CACHE_VERSION = 'obsigate-v5-pwa';
const STATIC_CACHE = CACHE_VERSION + '-static';
const DYNAMIC_CACHE = CACHE_VERSION + '-dynamic';
const MAX_DYNAMIC_CACHE_SIZE = 100;