fix: Sign out + login flow + cache bust for i18n
- 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:
+11
-4
@@ -4,6 +4,15 @@ import { safeCreateIcons } from './utils.js';
|
|||||||
import { showToast, closeHeaderMenu } from './ui.js';
|
import { showToast, closeHeaderMenu } from './ui.js';
|
||||||
import { t, getLocale } from './i18n.js';
|
import { t, getLocale } from './i18n.js';
|
||||||
import { showWelcome } from './viewer.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
|
// API helpers
|
||||||
@@ -201,9 +210,6 @@ const AuthManager = {
|
|||||||
const logoutBtn = document.getElementById("logout-btn");
|
const logoutBtn = document.getElementById("logout-btn");
|
||||||
if (logoutBtn) logoutBtn.addEventListener("click", () => AuthManager.logout());
|
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");
|
const adminRow = document.getElementById("admin-menu-row");
|
||||||
if (adminRow) {
|
if (adminRow) {
|
||||||
if (user.role === "admin") {
|
if (user.role === "admin") {
|
||||||
@@ -313,7 +319,8 @@ function initLoginForm() {
|
|||||||
// Load app data after successful login
|
// Load app data after successful login
|
||||||
try {
|
try {
|
||||||
await Promise.all([loadVaults(), loadTags()]);
|
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();
|
IndexUpdateManager.connect();
|
||||||
// Show dashboard
|
// Show dashboard
|
||||||
showWelcome();
|
showWelcome();
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
/* ObsiGate Service Worker - PWA v2 with IndexedDB offline support */
|
/* 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 STATIC_CACHE = CACHE_VERSION + '-static';
|
||||||
const DYNAMIC_CACHE = CACHE_VERSION + '-dynamic';
|
const DYNAMIC_CACHE = CACHE_VERSION + '-dynamic';
|
||||||
const MAX_DYNAMIC_CACHE_SIZE = 100;
|
const MAX_DYNAMIC_CACHE_SIZE = 100;
|
||||||
|
|||||||
Reference in New Issue
Block a user