ultisuite-client/lib/hooks/use-chrome-identity.ts
R3D347HR4Y 5304790ed5
Some checks are pending
E2E / Playwright e2e (push) Waiting to run
feat(auth): enhance session management and identity provider settings
- Added SessionGuard component to manage session expiration and online status.
- Updated AuthProvider to streamline session fetching and handling.
- Introduced IdentityProvidersSection for managing OAuth, SAML, and LDAP identity providers.
- Implemented identity provider guides for easier configuration.
- Enhanced mail settings with infinite scroll option for improved user experience.
- Updated global styles and layout components for better consistency across the application.
2026-06-09 09:36:46 +02:00

41 lines
1.1 KiB
TypeScript

"use client"
import { usePersistHydrated } from "@/hooks/use-persist-hydrated"
import { useAuthStore } from "@/lib/api/auth-store"
import { useAccountStore, useActiveAccount } from "@/lib/stores/account-store"
/** Identity shown in header avatar / account menu (OIDC user, else active mail account). */
export function useChromeIdentity(): {
name: string
email: string
firstName: string
} | null {
const authHydrated = usePersistHydrated(useAuthStore)
const accountHydrated = usePersistHydrated(useAccountStore)
const platformUser = useAuthStore((s) => s.user)
const mailAccount = useActiveAccount()
// Keep SSR and first client render identical until persist stores rehydrate.
if (!authHydrated) return null
if (!platformUser && !accountHydrated) return null
if (platformUser) {
return {
name: platformUser.name,
email: platformUser.email,
firstName: platformUser.firstName,
}
}
if (mailAccount) {
const firstName = mailAccount.name.split(/\s+/)[0] ?? mailAccount.name
return {
name: mailAccount.name,
email: mailAccount.email,
firstName,
}
}
return null
}