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.
This commit is contained in:
@@ -294,6 +294,19 @@ function initLoginForm() {
|
|||||||
try {
|
try {
|
||||||
await AuthManager.login(username, password, rememberMe);
|
await AuthManager.login(username, password, rememberMe);
|
||||||
AuthManager.showApp();
|
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
|
// Load app data after successful login
|
||||||
try {
|
try {
|
||||||
await Promise.all([loadVaults(), loadTags()]);
|
await Promise.all([loadVaults(), loadTags()]);
|
||||||
|
|||||||
Reference in New Issue
Block a user