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

@@ -82,7 +82,7 @@ class PersonSectionPreferenceTest extends TestCase
{
Sanctum::actingAs($this->orgAdmin);
$response = $this->putJson("/api/v1/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences", [
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences", [
'preferences' => [
['festival_section_id' => $this->sectionA->id, 'priority' => 1],
['festival_section_id' => $this->sectionB->id, 'priority' => 2],
@@ -114,7 +114,7 @@ class PersonSectionPreferenceTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
// First: set 2 preferences
$this->putJson("/api/v1/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences", [
$this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences", [
'preferences' => [
['festival_section_id' => $this->sectionA->id, 'priority' => 1],
['festival_section_id' => $this->sectionB->id, 'priority' => 2],
@@ -124,7 +124,7 @@ class PersonSectionPreferenceTest extends TestCase
$this->assertEquals(2, PersonSectionPreference::where('person_id', $this->person->id)->count());
// Second: replace with 1 different preference
$this->putJson("/api/v1/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences", [
$this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences", [
'preferences' => [
['festival_section_id' => $this->sectionC->id, 'priority' => 1],
],
@@ -146,7 +146,7 @@ class PersonSectionPreferenceTest extends TestCase
{
Sanctum::actingAs($this->orgAdmin);
$response = $this->putJson("/api/v1/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences", [
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences", [
'preferences' => [
['festival_section_id' => $this->sectionA->id, 'priority' => 1],
['festival_section_id' => $this->sectionB->id, 'priority' => 1],
@@ -161,7 +161,7 @@ class PersonSectionPreferenceTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
// Priority 0 should fail
$response = $this->putJson("/api/v1/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences", [
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences", [
'preferences' => [
['festival_section_id' => $this->sectionA->id, 'priority' => 0],
],
@@ -170,7 +170,7 @@ class PersonSectionPreferenceTest extends TestCase
$response->assertUnprocessable();
// Priority 6 should fail
$response = $this->putJson("/api/v1/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences", [
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences", [
'preferences' => [
['festival_section_id' => $this->sectionA->id, 'priority' => 6],
],
@@ -188,7 +188,7 @@ class PersonSectionPreferenceTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->putJson("/api/v1/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences", [
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences", [
'preferences' => [
['festival_section_id' => $this->sectionA->id, 'priority' => 1],
['festival_section_id' => $this->sectionB->id, 'priority' => 2],
@@ -212,7 +212,7 @@ class PersonSectionPreferenceTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->putJson("/api/v1/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences", [
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences", [
'preferences' => [
['festival_section_id' => $otherSection->id, 'priority' => 1],
],
@@ -225,7 +225,7 @@ class PersonSectionPreferenceTest extends TestCase
{
Sanctum::actingAs($this->orgAdmin);
$response = $this->putJson("/api/v1/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences", [
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences", [
'preferences' => [
['festival_section_id' => $this->crossEventSection->id, 'priority' => 1],
],
@@ -255,7 +255,7 @@ class PersonSectionPreferenceTest extends TestCase
Sanctum::actingAs($this->orgAdmin);
$response = $this->getJson("/api/v1/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences");
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences");
$response->assertOk();
$this->assertCount(2, $response->json('data'));
@@ -265,14 +265,14 @@ class PersonSectionPreferenceTest extends TestCase
{
Sanctum::actingAs($this->outsider);
$response = $this->getJson("/api/v1/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences");
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences");
$response->assertForbidden();
}
public function test_unauthenticated_returns_401(): void
{
$response = $this->getJson("/api/v1/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences");
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/persons/{$this->person->id}/section-preferences");
$response->assertUnauthorized();
}