security: A01-13 — nest all event routes under organisation prefix

Move all authenticated organiser-facing event sub-resource routes from
/events/{event}/... to /organisations/{organisation}/events/{event}/...
to enforce multi-tenancy at the routing layer.

Changes:
- Routes: restructured api.php to nest all event sub-resources under
  the existing organisation prefix group
- Controllers: added Organisation parameter and VerifiesOrganisationEvent
  trait to all 12 affected controllers (sections, time-slots, shifts,
  persons, crowd-lists, locations, shift-assignments, registration-fields,
  availabilities, field-values, section-preferences, stats)
- Tests: updated all 20 feature test files with new route paths
- Frontend: updated 8 API composables and 20 Vue components/pages
- API.md: updated documentation to reflect new route structure

Portal routes, public routes (volunteer-register), and invitation routes
remain unchanged as they operate without organisation context.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-14 08:16:36 +02:00
parent 51e5dd6fcb
commit 7932e53daf
64 changed files with 726 additions and 568 deletions

View File

@@ -50,7 +50,7 @@ class FestivalSectionTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->getJson("/api/v1/events/{$this->event->id}/sections");
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections");
$response->assertOk();
$this->assertCount(3, $response->json('data'));
@@ -60,7 +60,7 @@ class FestivalSectionTest extends TestCase
{
Sanctum::actingAs($this->outsider);
$response = $this->getJson("/api/v1/events/{$this->event->id}/sections");
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections");
$response->assertForbidden();
}
@@ -69,7 +69,7 @@ class FestivalSectionTest extends TestCase
{
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->event->id}/sections", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections", [
'name' => 'Bar',
'sort_order' => 1,
]);
@@ -85,7 +85,7 @@ class FestivalSectionTest extends TestCase
public function test_store_unauthenticated_returns_401(): void
{
$response = $this->postJson("/api/v1/events/{$this->event->id}/sections", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections", [
'name' => 'Bar',
'sort_order' => 1,
]);
@@ -97,7 +97,7 @@ class FestivalSectionTest extends TestCase
{
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->event->id}/sections", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections", [
'sort_order' => 1,
]);
@@ -114,7 +114,7 @@ class FestivalSectionTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->putJson("/api/v1/events/{$this->event->id}/sections/{$section->id}", [
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/{$section->id}", [
'name' => 'Bar Updated',
]);
@@ -128,7 +128,7 @@ class FestivalSectionTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->deleteJson("/api/v1/events/{$this->event->id}/sections/{$section->id}");
$response = $this->deleteJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/{$section->id}");
$response->assertNoContent();
$this->assertSoftDeleted('festival_sections', ['id' => $section->id]);
@@ -140,7 +140,7 @@ class FestivalSectionTest extends TestCase
Sanctum::actingAs($this->outsider);
$response = $this->putJson("/api/v1/events/{$this->event->id}/sections/{$section->id}", [
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/{$section->id}", [
'name' => 'Hacked',
]);
@@ -153,7 +153,7 @@ class FestivalSectionTest extends TestCase
Sanctum::actingAs($this->outsider);
$response = $this->deleteJson("/api/v1/events/{$this->event->id}/sections/{$section->id}");
$response = $this->deleteJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/{$section->id}");
$response->assertForbidden();
}
@@ -162,7 +162,7 @@ class FestivalSectionTest extends TestCase
{
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->event->id}/sections", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections", [
'name' => 'Tapkraan',
'category' => 'Bar',
'icon' => 'tabler-beer',
@@ -237,7 +237,7 @@ class FestivalSectionTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/events/{$this->event->id}/sections/reorder", [
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/reorder", [
'sections' => [$sectionB->id, $sectionA->id],
]);