Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ What the app is and how to run it: [`README.md`](README.md). UI rules: [`docs/de

## Architecture

- **Routes** (`src/routes/`): `/dashboard` loads `me.access` via the BFF and requires `admin:access`. The route context
- **Routes** (`src/routes/`): `/dashboard` loads a fresh `me.access` via the BFF. Authenticated applicants can open Associazioni; internal areas retain their exact permissions. The route context
carries display user data and permissions, never tokens. Navigation and mutation controls use exact permissions.
- **Auth**: `/auth/login`, `/auth/callback` and POST `/auth/logout` implement OIDC with PKCE/state/nonce through
`openid-client`. ID tokens are signature-checked. Tokens remain in the dedicated Redis server session store.
Expand Down Expand Up @@ -52,6 +52,8 @@ What the app is and how to run it: [`README.md`](README.md). UI rules: [`docs/de
from a server function, never a token. UI copy is Italian. Details: `docs/regulations/README.md`.
- **Shared UI**: `src/components/shell`, `src/components/primitives`, `src/components/ui`.

- **Associazioni** (`src/features/association-portal/`): register, representatives and review; see `docs/associations/README.md`. The shell admits every signed-in account with a fresh `me.access`, so any function using `dashboardUserMiddleware` must add its own permission check; `associationSelfMiddleware` grants none. Operator commands (`operatorActions` in `portal.contract.ts`) go through `reviewPortalAssociation` (`web:content:write`); `changePortalAssociation` accepts only `applicantActions`. The backend checks membership on every call. UI copy is Italian.

## Conventions

`pnpm test` enforces the items marked (test); its failure messages name what to add.
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,7 @@ Logout deletes the server session, attempts refresh revocation, and redirects to
requests require an `Origin` exactly equal to `APP_URL`'s configured origin. Sessions and identity responses are not
cacheable. Production cookies are host-only, `Secure`, `HttpOnly`, `SameSite=Lax`; tokens and client keys never appear
in browser storage or route loader output.

## Associazioni

Registro, accesso dei referenti e pubblicazione moderata: [flussi e rilascio](docs/associations/README.md).
42 changes: 42 additions & 0 deletions docs/associations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Registro e portale delle associazioni

Ogni persona accede a `admin.polinetwork.org` con il proprio account. Non riceve permessi amministrativi globali: il backend verifica a ogni operazione il collegamento alla singola associazione. Gli operatori PoliNetwork che possiedono insieme `admin:access` e `web:content:write` gestiscono registro e approvazioni.

## Tre decisioni distinte

1. **Registrazione**: la persona propone nome, sigla, informazioni e motivazione privata del proprio ruolo. PoliNetwork verifica e approva l'associazione e il primo responsabile. Una registrazione inserita direttamente da un operatore può rimanere senza referenti.
2. **Rappresentanza**: una persona richiede accesso a un'associazione esistente, oppure riceve un invito. L'invito si accetta con un account personale e PoliNetwork approva esattamente quell'account. Nome ed email non assegnano mai automaticamente accesso.
3. **Pubblicazione**: responsabili e collaboratori preparano una proposta; il responsabile la invia. Solo l'approvazione PoliNetwork cambia la scheda pubblicata. Registrare un'associazione non la pubblica.

Una richiesta duplicata di registrazione può essere trasferita da PoliNetwork al record esistente come richiesta di accesso, senza attribuire automaticamente alcun ruolo.

## Ruoli e schermate

| Persona | Funzioni |
| ------------------------------ | ---------------------------------------------------------------------------------------------------------- |
| Autenticata senza collegamenti | Registra un'associazione, cerca il registro per nome, chiede accesso, segue le proprie richieste |
| Collaboratore | Legge la propria associazione e prepara modifiche della scheda |
| Responsabile | Anche invio per pubblicazione, inviti e proposte di modifica dei referenti |
| Operatore PoliNetwork | Registro completo, richieste, approvazioni, note interne, sospensione, oscuramento, archiviazione e revoca |

`/dashboard/associations` presenta le associazioni accessibili, le richieste e la ricerca per chiedere accesso. Il dettaglio separa scheda, richieste, referenti e attività. L'invito atterra su `/associations/invite`, conserva il ritorno dopo il login e mostra l'account prima dell'accettazione.

La scheda comprende nome, sigla, descrizioni italiana e inglese, email pubblica, logo e fino a 30 link con piattaforma, etichetta e URL. Si possono inserire più link Telegram, Twitch o altri canali della stessa piattaforma. Il logo può essere un URL HTTP/S oppure un PNG/JPEG fino a 1 MiB caricato dopo il salvataggio iniziale. Motivazioni di rappresentanza, email degli inviti e note interne non finiscono sul sito pubblico.

## Stati e gestione dei referenti

Le richieste passano per bozza, invio, eventuali integrazioni, approvazione/rifiuto o ritiro. Le modifiche inviate restano separate dalla versione pubblicata, anche durante un rifiuto. La scheda richiede entrambe le descrizioni per essere pubblicata.

Gli inviti scadono dopo 14 giorni, sono monouso e sono invalidati dal ritiro. Ogni nuovo collegamento e ogni cambio di ruolo richiede approvazione. La rimozione ordinaria dell'ultimo responsabile richiede prima un sostituto; l'abbandono personale o una revoca esplicita PoliNetwork sono immediati e lasciano il record segnalato come privo di responsabile.

La sospensione blocca le modifiche dei referenti e può mantenere visibile la scheda; l'oscuramento la rimuove dal sito. L'archiviazione conserva registro e storico, blocca la gestione e oscura la scheda. Le note interne sono visibili solo agli operatori. Ogni richiedente vede soltanto le proprie evidenze; i referenti vedono anche le proposte di contenuto della propria associazione.

## Contratto e rilascio

Il backend espone `associationPortal.*`. Il BFF valida tutte le risposte con `portal.contract.ts`, copia del contratto backend. Login OIDC, sessioni Redis e controllo Origin restano quelli esistenti. L'accesso alla shell è aperto agli account autenticati con una risposta fresca di `me.access`; i singoli servizi interni continuano a richiedere i propri permessi.

Il backend conserva registro, richieste, storico e collegamenti in un aggregato transazionale PostgreSQL. Revisioni ottimistiche, blocchi di riga e chiavi di idempotenza proteggono da approvazioni concorrenti e retry. Le email usano una coda durevole con retry; lo stato è consultabile anche nel portale. Nessuna modifica deve essere ripetuta solo perché il successivo aggiornamento della pagina fallisce.

Le tre PR vanno coordinate: migrazione e backend, poi admin; il sito supporta sia la vecchia risposta sia `extraLinks`. Durante il breve intervallo tra backend e admin, il vecchio editor rifiuta le scritture. La migrazione conserva identificativi e schede pubbliche esistenti, senza assegnare referenti. Verificare `ESIGN_DASHBOARD_URL=https://admin.polinetwork.org`, configurazione email e storage Azure del backend. Non sono richieste nuove autorizzazioni globali nel repository Auth.

Il rilascio richiede backup e normale procedura di migrazione del backend. Queste PR non eseguono migrazioni né deployment in produzione. Dopo il rilascio verificare login reale, consegna invito via email e caricamento logo contro i servizi configurati; la prova automatizzata locale usa account e recapiti fittizi.
37 changes: 30 additions & 7 deletions src/components/shell/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export type DashboardPath = Extract<keyof FileRoutesByTo, `/dashboard${string}`>

export type ServiceId =
| "overview"
| "associations"
| "people"
| "telegram"
| "whatsapp"
Expand Down Expand Up @@ -115,6 +116,8 @@ export type Service = {

export type PageMatch =
| { kind: "overview" }
| { kind: "association-portal" }
| { kind: "association-detail"; id: string }
| { kind: "account" }
| { kind: "account-me" }
| { kind: "people-overview" }
Expand Down Expand Up @@ -357,13 +360,6 @@ const web: Service = {
path: "/dashboard/web/projects",
sections: [
{ id: "projects", title: "Projects", icon: FolderKanban, path: "/dashboard/web/projects" },
{
id: "associations",
title: "Associations",
icon: Users,
path: "/dashboard/web/associations",
searchPlaceholder: "Search associations…",
},
{ id: "freshman", title: "Freshman", icon: BookOpen, path: "/dashboard/web/freshman" },
{
id: "faqs",
Expand Down Expand Up @@ -456,6 +452,23 @@ const regulations: Service = {
],
}

const associations: Service = {
id: "associations",
title: "Associazioni",
short: "Associazioni",
icon: UsersRound,
path: "/dashboard/associations",
sections: [
{
id: "portal",
title: "Le mie associazioni",
icon: UsersRound,
path: "/dashboard/associations",
selfService: true,
},
],
}

const reports: Service = {
id: "reports",
title: "Reports",
Expand Down Expand Up @@ -485,6 +498,7 @@ const reports: Service = {
/** Rail order: Overview, services with sections, then Account. */
export const services: Service[] = [
overview,
associations,
people,
telegram,
whatsapp,
Expand Down Expand Up @@ -553,6 +567,8 @@ export function matchPath(pathname: string): PageMatch {
const [head, second, third, ...rest] = segments

if (head === undefined) return { kind: "overview" }
if (head === "associations" && third === undefined)
return second ? { kind: "association-detail", id: second } : { kind: "association-portal" }
if (head === "account" && second === undefined) return { kind: "account" }
if (head === "account" && second === "me" && third === undefined && rest.length === 0) return { kind: "account-me" }

Expand Down Expand Up @@ -647,6 +663,9 @@ export function matchPath(pathname: string): PageMatch {

export function serviceFor(match: PageMatch): Service {
switch (match.kind) {
case "association-portal":
case "association-detail":
return associations
case "overview":
case "not-found":
return overview
Expand Down Expand Up @@ -711,6 +730,9 @@ export function serviceFor(match: PageMatch): Service {
/** The panel section a page belongs to. Deep pages return their parent section (see `isDeepPage`). */
export function sectionFor(match: PageMatch): Section | null {
switch (match.kind) {
case "association-portal":
case "association-detail":
return section(associations, "portal")
case "overview":
case "not-found":
return null
Expand Down Expand Up @@ -797,6 +819,7 @@ export function sectionFor(match: PageMatch): Section | null {
/** Deep pages are reached from a section but are not themselves in the panel. */
export function isDeepPage(match: PageMatch): boolean {
return (
match.kind === "association-detail" ||
match.kind === "telegram-user" ||
match.kind === "web-category" ||
match.kind === "web-tag" ||
Expand Down
Loading
Loading