registri dei piani in git (AI-OS#309)

Refs gitea:Adriano/AI-OS#310

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-10-06 10:36:26 +02:00
parent 9126af28ce
commit b913a2bf90
94 changed files with 40294 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
### Task 3: Middleware con matrice e redirect per ruolo
**Files:**
- Modify: `src/middleware.ts`
**Interfaces:**
- Consumes: `canAccessAdminPath`, `landingFor` (Task 2).
- [ ] **Step 1: Aggiorna il middleware**
In `src/middleware.ts` cambia l'import e il ramo autorizzazione. Import:
```typescript
import { getSessionUser, SESSION_COOKIE, canAccessAdminPath, landingFor } from './lib/auth';
```
Sostituisci il blocco `if (!canAccessAdminPath(...))` con:
```typescript
if (!canAccessAdminPath(user.role, pathname)) {
if (pathname.startsWith('/api/')) {
return new Response(JSON.stringify({ error: 'Permessi insufficienti' }), {
status: 403, headers: { 'Content-Type': 'application/json' },
});
}
return context.redirect(landingFor(user.role));
}
```
- [ ] **Step 2: Verifica build + type check**
Run: `npm run build`
Expected: build OK, nessun errore di tipo.
- [ ] **Step 3: Commit**
```bash
git add src/middleware.ts
git commit -m "feat(middleware): autorizzazione a matrice + redirect per ruolo"
```
---