### Task 8: Header SSR con identità utente **Files:** - Modify: `src/layouts/Base.astro` - Modify: `src/components/Header.astro` **Interfaces:** - Consumes: `getSessionUser`, `SESSION_COOKIE` (auth.ts). - Produces: `Header` accetta `Props { user: { username: string; role: string } | null; showTags: boolean; canTags: boolean }`. In questo task `showTags`/`canTags` sono passati ma il toggle è aggiunto nel Task 9 (qui il menu mostra solo identità + area riservata + esci). - [ ] **Step 1: Calcola la sessione in `Base.astro` e passala all'header** In `src/layouts/Base.astro`, sostituisci il blocco `// Overlay annotate...` con: ```typescript const tok = Astro.cookies.get(SESSION_COOKIE)?.value; const user = tok ? getSessionUser(getDb(), tok) : null; const canTags = !!user && (user.role === 'superuser' || user.role === 'admin'); const wantTags = Astro.cookies.get('showtags')?.value === '1' || Astro.url.searchParams.get('annotate') === '1'; const showTags = canTags && wantTags; ``` E cambia `
` in: ```astro
``` (La sostituzione della variabile `annotate` con `showTags` nell'overlay avviene nel Task 10; per ora l'overlay resta gestito da `showTags` — aggiorna il blocco `{annotate && (` in `{showTags && (` già qui, così la pagina compila.) - [ ] **Step 2: Rendi l'header consapevole della sessione** Sostituisci il frontmatter e il markup di `src/components/Header.astro`: ```astro --- import { site } from '../data/site'; import { t, contentImageUrl } from '../lib/content'; interface Props { user: { username: string; role: string } | null; showTags: boolean; canTags: boolean; } const { user, canTags } = Astro.props; const path = Astro.url.pathname; const loginHref = `/login?next=${encodeURIComponent(path)}`; const areaHref = user?.role === 'superuser' ? '/admin/content' : '/admin'; --- ``` Aggiungi in fondo al blocco `