diff --git a/components/settings/account-settings.tsx b/components/settings/account-settings.tsx index 1083e0cb..3e70b9cd 100644 --- a/components/settings/account-settings.tsx +++ b/components/settings/account-settings.tsx @@ -3,29 +3,44 @@ import { useTranslations } from 'next-intl'; import { useAuthStore } from '@/stores/auth-store'; import { useEmailStore } from '@/stores/email-store'; +import { useAccountStore } from '@/stores/account-store'; import { SettingsSection, SettingItem } from './settings-section'; import { formatFileSize } from '@/lib/utils'; export function AccountSettings() { const t = useTranslations('settings.account'); - const { username, serverUrl, isDemoMode, primaryIdentity } = useAuthStore(); + const { username, serverUrl, isDemoMode, primaryIdentity, authMode, activeAccountId } = useAuthStore(); const { quota } = useEmailStore(); + const account = useAccountStore((s) => activeAccountId ? s.getAccountById(activeAccountId) : undefined); const quotaPercentage = quota ? Math.round((quota.used / quota.total) * 100) : 0; - const displayName = primaryIdentity?.name || (isDemoMode ? 'Demo User' : undefined); + const displayName = primaryIdentity?.name || account?.displayName || (isDemoMode ? 'Demo User' : undefined); + const email = primaryIdentity?.email || account?.email || username; return ( - {/* Display Name (show in demo mode or when identity has a name) */} - {displayName && ( - - {displayName} - - )} + {/* Display Name */} + + {displayName || t('../../common.unknown')} + {/* Email Address */} - {username || t('../../common.unknown')} + {email || t('../../common.unknown')} + + + {/* Username / Login (show when it differs from email) */} + {username && username !== email && ( + + {username} + + )} + + {/* Authentication Method */} + + + {authMode === 'oauth' ? t('auth_method_oauth') : t('auth_method_basic')} + {/* Server */} diff --git a/locales/de/common.json b/locales/de/common.json index 17cb3f22..264cd1b5 100644 --- a/locales/de/common.json +++ b/locales/de/common.json @@ -913,7 +913,11 @@ "title": "Konto", "description": "Zeigen Sie Ihre Kontoinformationen an", "name_label": "Anzeigename", + "username_label": "Benutzername", "account_type_label": "Kontotyp", + "auth_method_label": "Authentifizierung", + "auth_method_oauth": "Single Sign-On (OAuth/OIDC)", + "auth_method_basic": "Passwort", "demo_account": "Demokonto", "email": { "label": "E-Mail-Adresse", diff --git a/locales/en/common.json b/locales/en/common.json index 5f6b9e79..6d84985b 100644 --- a/locales/en/common.json +++ b/locales/en/common.json @@ -913,7 +913,11 @@ "title": "Account", "description": "View your account information", "name_label": "Display Name", + "username_label": "Username", "account_type_label": "Account Type", + "auth_method_label": "Authentication", + "auth_method_oauth": "Single Sign-On (OAuth/OIDC)", + "auth_method_basic": "Password", "demo_account": "Demo Account", "email": { "label": "Email Address", diff --git a/locales/es/common.json b/locales/es/common.json index be56888b..e9eba747 100644 --- a/locales/es/common.json +++ b/locales/es/common.json @@ -913,7 +913,11 @@ "title": "Cuenta", "description": "Vea la información de su cuenta", "name_label": "Nombre para mostrar", + "username_label": "Nombre de usuario", "account_type_label": "Tipo de cuenta", + "auth_method_label": "Autenticación", + "auth_method_oauth": "Inicio de sesión único (OAuth/OIDC)", + "auth_method_basic": "Contraseña", "demo_account": "Cuenta de demostración", "email": { "label": "Dirección de Correo", diff --git a/locales/fr/common.json b/locales/fr/common.json index d8b2c506..90961771 100644 --- a/locales/fr/common.json +++ b/locales/fr/common.json @@ -913,7 +913,11 @@ "title": "Compte", "description": "Consultez les informations de votre compte", "name_label": "Nom d'affichage", + "username_label": "Nom d'utilisateur", "account_type_label": "Type de compte", + "auth_method_label": "Authentification", + "auth_method_oauth": "Authentification unique (OAuth/OIDC)", + "auth_method_basic": "Mot de passe", "demo_account": "Compte de démonstration", "email": { "label": "Adresse email", diff --git a/locales/it/common.json b/locales/it/common.json index 580e69df..efc099b6 100644 --- a/locales/it/common.json +++ b/locales/it/common.json @@ -913,7 +913,11 @@ "title": "Account", "description": "Visualizza le informazioni del tuo account", "name_label": "Nome visualizzato", + "username_label": "Nome utente", "account_type_label": "Tipo di account", + "auth_method_label": "Autenticazione", + "auth_method_oauth": "Single Sign-On (OAuth/OIDC)", + "auth_method_basic": "Password", "demo_account": "Account dimostrativo", "email": { "label": "Indirizzo email", diff --git a/locales/ja/common.json b/locales/ja/common.json index 4b7c6a8c..c5fabf87 100644 --- a/locales/ja/common.json +++ b/locales/ja/common.json @@ -913,7 +913,11 @@ "title": "アカウント", "description": "アカウント情報を表示", "name_label": "表示名", + "username_label": "ユーザー名", "account_type_label": "アカウントタイプ", + "auth_method_label": "認証方法", + "auth_method_oauth": "シングルサインオン (OAuth/OIDC)", + "auth_method_basic": "パスワード", "demo_account": "デモアカウント", "email": { "label": "メールアドレス", diff --git a/locales/nl/common.json b/locales/nl/common.json index 0820189b..a681520b 100644 --- a/locales/nl/common.json +++ b/locales/nl/common.json @@ -913,7 +913,11 @@ "title": "Account", "description": "Bekijk je accountinformatie", "name_label": "Weergavenaam", + "username_label": "Gebruikersnaam", "account_type_label": "Accounttype", + "auth_method_label": "Authenticatie", + "auth_method_oauth": "Single Sign-On (OAuth/OIDC)", + "auth_method_basic": "Wachtwoord", "demo_account": "Demoaccount", "email": { "label": "E-mailadres", diff --git a/locales/pt/common.json b/locales/pt/common.json index 9e45864c..325c5235 100644 --- a/locales/pt/common.json +++ b/locales/pt/common.json @@ -913,7 +913,11 @@ "title": "Conta", "description": "Visualize as informações da sua conta", "name_label": "Nome de exibição", + "username_label": "Nome de usuário", "account_type_label": "Tipo de conta", + "auth_method_label": "Autenticação", + "auth_method_oauth": "Login único (OAuth/OIDC)", + "auth_method_basic": "Senha", "demo_account": "Conta de demonstração", "email": { "label": "Endereço de E-mail", diff --git a/stores/auth-store.ts b/stores/auth-store.ts index 338c43c2..f5f29939 100644 --- a/stores/auth-store.ts +++ b/stores/auth-store.ts @@ -486,8 +486,12 @@ export const useAuthStore = create()( }); await client.connect(); - const username = client.getUsername(); - const { identities, primaryIdentity } = loadIdentities(await client.getIdentities(), username); + const jmapUsername = client.getUsername(); + const { identities, primaryIdentity } = loadIdentities(await client.getIdentities(), jmapUsername); + // For OAuth/OIDC, the JMAP session account name may be the + // preferred_username claim rather than the real email address. + // Prefer the email from the primary identity when available. + const username = primaryIdentity?.email || jmapUsername; initializeFeatureStores(client); // Register in account store @@ -602,8 +606,12 @@ export const useAuthStore = create()( }); await client.connect(); - const username = client.getUsername(); - const { identities, primaryIdentity } = loadIdentities(await client.getIdentities(), username); + const jmapUsername = client.getUsername(); + const { identities, primaryIdentity } = loadIdentities(await client.getIdentities(), jmapUsername); + // For SSO/OIDC, the JMAP session account name may be the + // preferred_username claim rather than the real email address. + // Prefer the email from the primary identity when available. + const username = primaryIdentity?.email || jmapUsername; initializeFeatureStores(client); const accountId = generateAccountId(username, ssoServerUrl);