fix: re-sync language from server after login
CI / lint (push) Failing after 26s
CI / test (push) Has been skipped
CI / build (push) Has been skipped
CI / e2e (push) Has been skipped
CI / security (push) Failing after 10s

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.
This commit is contained in:
2026-06-21 11:06:27 -04:00
parent 98a6dd8a2c
commit dec46cd5ab
+13
View File
@@ -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()]);