Multi-tenancy : espaces de travail + fix auth reload (rate limiter OPTIONS)

- Modèles Organization + OrgMember, migration Alembic (SQLite compatible)
- organization_id nullable sur Document, Decision, Mandate, VotingProtocol
- Service, schéma, router /organizations + dependency get_active_org_id
- Seed : Duniter G1 + Axiom Team ; tout le contenu seed attaché à Duniter G1
- Backend : list/create filtrés par header X-Organization
- Frontend : store organizations, WorkspaceSelector réel, useApi injecte l'org
- Fix critique : rate_limiter exclut les requêtes OPTIONS (CORS preflight)
  → résout le bug "Failed to fetch /auth/me" au reload (429 sur preflight)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Yvv
2026-04-23 15:17:14 +02:00
parent 224e5b0f5e
commit 79e468b40f
31 changed files with 1296 additions and 159 deletions

View File

@@ -73,6 +73,7 @@ function isRetryable(status: number): boolean {
export function useApi() {
const config = useRuntimeConfig()
const auth = useAuthStore()
const orgsStore = useOrganizationsStore()
/**
* Perform a typed fetch against the backend API.
@@ -94,6 +95,9 @@ export function useApi() {
if (auth.token) {
headers.Authorization = `Bearer ${auth.token}`
}
if (orgsStore.activeSlug) {
headers['X-Organization'] = orgsStore.activeSlug
}
const maxAttempts = noRetry ? 1 : MAX_RETRIES
let lastError: any = null