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

@@ -89,7 +89,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->volunteer);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/claim",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/claim",
['person_id' => $this->person->id],
);
@@ -115,7 +115,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->volunteer);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/sections/{$autoSection->id}/shifts/{$shift->id}/claim",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/{$autoSection->id}/shifts/{$shift->id}/claim",
['person_id' => $this->person->id],
);
@@ -142,7 +142,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->volunteer);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/claim",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/claim",
['person_id' => $this->person->id],
);
@@ -162,7 +162,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->volunteer);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/claim",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/claim",
['person_id' => $this->person->id],
);
@@ -185,7 +185,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->volunteer);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift2->id}/claim",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift2->id}/claim",
['person_id' => $this->person->id],
);
@@ -208,7 +208,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->volunteer);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift2->id}/claim",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift2->id}/claim",
['person_id' => $this->person->id],
);
@@ -227,7 +227,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->volunteer);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/claim",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/claim",
['person_id' => $pendingPerson->id],
);
@@ -239,7 +239,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
$shift = $this->createOpenShift();
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/claim",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/claim",
['person_id' => $this->person->id],
);
@@ -257,7 +257,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/assign",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/assign",
['person_id' => $this->person->id],
);
@@ -282,7 +282,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/assign",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/assign",
['person_id' => $this->person->id],
);
@@ -306,7 +306,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/assign",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/assign",
['person_id' => $this->person->id],
);
@@ -333,7 +333,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift2->id}/assign",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift2->id}/assign",
['person_id' => $this->person->id],
);
@@ -347,7 +347,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->volunteer);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/assign",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/assign",
['person_id' => $this->person->id],
);
@@ -371,7 +371,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/shift-assignments/{$assignment->id}/approve",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/shift-assignments/{$assignment->id}/approve",
);
$response->assertOk()
@@ -397,7 +397,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/shift-assignments/{$assignment->id}/reject",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/shift-assignments/{$assignment->id}/reject",
['reason' => 'Onvoldoende ervaring voor deze rol.'],
);
@@ -418,7 +418,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/shift-assignments/{$assignment->id}/approve",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/shift-assignments/{$assignment->id}/approve",
);
$response->assertUnprocessable();
@@ -437,7 +437,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->volunteer);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/shift-assignments/{$assignment->id}/cancel",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/shift-assignments/{$assignment->id}/cancel",
);
$response->assertOk()
@@ -456,7 +456,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->volunteer);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/shift-assignments/{$assignment->id}/cancel",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/shift-assignments/{$assignment->id}/cancel",
);
$response->assertOk()
@@ -480,7 +480,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->volunteer);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/shift-assignments/{$assignment->id}/cancel",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/shift-assignments/{$assignment->id}/cancel",
);
$response->assertForbidden();
@@ -502,7 +502,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/shift-assignments/{$assignment->id}/cancel",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/shift-assignments/{$assignment->id}/cancel",
);
$response->assertOk()
@@ -530,7 +530,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/shift-assignments/bulk-approve",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/shift-assignments/bulk-approve",
['assignment_ids' => $assignments->pluck('id')->toArray()],
);
@@ -570,7 +570,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/shift-assignments/bulk-approve",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/shift-assignments/bulk-approve",
['assignment_ids' => [$pending->id, $approved->id]],
);
@@ -605,7 +605,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->getJson("/api/v1/events/{$this->event->id}/shift-assignments");
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/shift-assignments");
$response->assertOk();
$this->assertCount(3, $response->json('data'));
@@ -633,7 +633,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->getJson("/api/v1/events/{$this->event->id}/shift-assignments?status=pending_approval");
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/shift-assignments?status=pending_approval");
$response->assertOk();
$this->assertCount(1, $response->json('data'));
@@ -651,7 +651,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->outsider);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/claim",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/sections/{$this->section->id}/shifts/{$shift->id}/claim",
['person_id' => $this->person->id],
);
@@ -671,7 +671,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->outsider);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/shift-assignments/{$assignment->id}/approve",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/shift-assignments/{$assignment->id}/approve",
);
$response->assertForbidden();
@@ -688,7 +688,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/persons/{$this->person->id}/availabilities/sync",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/persons/{$this->person->id}/availabilities/sync",
[
'availabilities' => [
['time_slot_id' => $this->timeSlot->id, 'preference_level' => 5],
@@ -721,7 +721,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/persons/{$this->person->id}/availabilities/sync",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/persons/{$this->person->id}/availabilities/sync",
[
'availabilities' => [
['time_slot_id' => $slot2->id, 'preference_level' => 4],
@@ -752,7 +752,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/persons/{$this->person->id}/availabilities/sync",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/persons/{$this->person->id}/availabilities/sync",
[
'availabilities' => [
['time_slot_id' => $otherSlot->id, 'preference_level' => 3],
@@ -766,7 +766,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
public function test_unauthenticated_sync_returns_401(): void
{
$response = $this->postJson(
"/api/v1/events/{$this->event->id}/persons/{$this->person->id}/availabilities/sync",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/persons/{$this->person->id}/availabilities/sync",
['availabilities' => []],
);
@@ -784,7 +784,7 @@ class ShiftAssignmentWorkflowTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->getJson(
"/api/v1/events/{$this->event->id}/persons/{$this->person->id}/availabilities",
"/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/persons/{$this->person->id}/availabilities",
);
$response->assertOk();