From dec46cd5ab47ee82104d69459acf3fe7bb617446 Mon Sep 17 00:00:00 2001 From: Bruno Charest Date: Sun, 21 Jun 2026 11:06:27 -0400 Subject: [PATCH] fix: re-sync language from server after login Root cause: initI18n() runs before auth on login page, so /api/auth/me fails (401) and locale falls back to browser language. After login, showWelcome() renders with stale locale without re-checking server preference. French users always got French UI. Fix: after successful login, fetch /api/auth/me and call setLocale() if server language differs from current. This ensures the dashboard renders in the user's saved language preference. --- frontend/js/auth.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frontend/js/auth.js b/frontend/js/auth.js index b0f04da..ba08c06 100644 --- a/frontend/js/auth.js +++ b/frontend/js/auth.js @@ -294,6 +294,19 @@ function initLoginForm() { try { await AuthManager.login(username, password, rememberMe); AuthManager.showApp(); + + // Re-sync language from server now that we're authenticated + try { + const resp = await fetch('/api/auth/me', { credentials: 'include' }); + if (resp.ok) { + const user = await resp.json(); + if (user.language && user.language !== getLocale()) { + const { setLocale } = await import('./i18n.js'); + await setLocale(user.language); + } + } + } catch (e) { /* non-bloquant */ } + // Load app data after successful login try { await Promise.all([loadVaults(), loadTags()]);