092ccb7bda
first user-visible piece of the auth track. portal-shell now consumes
the bff auth surface and the header reflects sign-in state.
libs/feature/auth replaces the empty nx scaffold with an AuthService
that:
- fetches /api/auth/me on first injection (unawaited so the first
paint isn't blocked behind the round-trip).
- holds a signal-backed discriminated AuthState — loading /
anonymous / authenticated / error — so templates switch on .kind
and the type narrows automatically.
- exposes currentUser + isLoading computed signals on top.
- provides login() / logout() / refresh() methods. navigation
goes through an injected AUTH_NAVIGATOR token whose default
calls window.location.assign(url) — tests substitute a vi.fn()
instead of redefining window.location (which jsdom resists
across multiple specs in the same file).
distinct error state vs. anonymous: a network failure surfaces a
"Can't reach the server" chip; a 401 surfaces the sign-in button.
treating any /me failure as anonymous would silently hide outages.
curated CurrentUser type mirrors the bff's /me response (oid, tid,
username, displayName) — no amr, no internal claims. consumers
import it without pulling in angular http types.
the host wires AUTH_BFF_BASE_URL from environment.ts (per adr-0018)
and AUTH_NAVIGATOR is providedIn:'root' with the window.location
default, so apps don't need to touch it. tsconfig.app.json picks up
the new lib reference via `nx sync`.
header user-widget renders four states with i18n message ids
(header.signIn / header.signOut / header.userMenu.loading /
header.authError). avatar shows the user's initials computed from
displayName ("JD" for "Jane Doe"); display name shows on sm: and
up so the rail stays compact on narrow viewports.
out of scope (next prs):
- route guards
- auto-refresh before idle timeout
- http interceptor that redirects to /auth/login on bff 401s
21 lines
397 B
JSON
21 lines
397 B
JSON
{
|
|
"extends": "./tsconfig.json",
|
|
"compilerOptions": {
|
|
"outDir": "../../dist/out-tsc",
|
|
"types": ["@angular/localize"]
|
|
},
|
|
"include": ["src/**/*.ts"],
|
|
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"],
|
|
"references": [
|
|
{
|
|
"path": "../../libs/shared/state"
|
|
},
|
|
{
|
|
"path": "../../libs/shared/ui"
|
|
},
|
|
{
|
|
"path": "../../libs/feature/auth"
|
|
}
|
|
]
|
|
}
|