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:
@@ -62,7 +62,7 @@ class PersonFieldValueTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->putJson("/api/v1/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
'values' => [
|
||||
$field->slug => 'Jan Jansen',
|
||||
],
|
||||
@@ -85,7 +85,7 @@ class PersonFieldValueTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->putJson("/api/v1/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
'values' => [
|
||||
$field->slug => 'M',
|
||||
],
|
||||
@@ -108,7 +108,7 @@ class PersonFieldValueTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->putJson("/api/v1/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
'values' => [
|
||||
$field->slug => 'XXXXL',
|
||||
],
|
||||
@@ -125,7 +125,7 @@ class PersonFieldValueTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->putJson("/api/v1/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
'values' => [
|
||||
$field->slug => ['Vegetarisch', 'Glutenvrij'],
|
||||
],
|
||||
@@ -153,7 +153,7 @@ class PersonFieldValueTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->putJson("/api/v1/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
'values' => [
|
||||
$field->slug => true,
|
||||
],
|
||||
@@ -180,7 +180,7 @@ class PersonFieldValueTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->putJson("/api/v1/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
'values' => [
|
||||
$field->slug => null,
|
||||
],
|
||||
@@ -206,7 +206,7 @@ class PersonFieldValueTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->putJson("/api/v1/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
'values' => [
|
||||
$field->slug => [$tag1->id, $tag2->id],
|
||||
],
|
||||
@@ -230,7 +230,7 @@ class PersonFieldValueTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->putJson("/api/v1/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
'values' => [
|
||||
$field->slug => ['01JFAKE00000000000000TAGID'],
|
||||
],
|
||||
@@ -257,7 +257,7 @@ class PersonFieldValueTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->putJson("/api/v1/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
'values' => [
|
||||
$field->slug => [$tag->id],
|
||||
],
|
||||
@@ -288,7 +288,7 @@ class PersonFieldValueTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->putJson("/api/v1/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/persons/{$this->person->id}/field-values", [
|
||||
'values' => [
|
||||
$field->slug => [$tag->id],
|
||||
],
|
||||
@@ -316,7 +316,7 @@ class PersonFieldValueTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->getJson("/api/v1/events/{$this->event->id}/persons/{$this->person->id}/field-values");
|
||||
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/persons/{$this->person->id}/field-values");
|
||||
|
||||
$response->assertOk();
|
||||
$this->assertCount(1, $response->json('data'));
|
||||
@@ -338,7 +338,7 @@ class PersonFieldValueTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$this->deleteJson("/api/v1/events/{$this->event->id}/registration-fields/{$field->id}")
|
||||
$this->deleteJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields/{$field->id}")
|
||||
->assertNoContent();
|
||||
|
||||
// Value persists with FK set to null (nullOnDelete)
|
||||
@@ -353,14 +353,14 @@ class PersonFieldValueTest extends TestCase
|
||||
{
|
||||
Sanctum::actingAs($this->outsider);
|
||||
|
||||
$response = $this->getJson("/api/v1/events/{$this->event->id}/persons/{$this->person->id}/field-values");
|
||||
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/persons/{$this->person->id}/field-values");
|
||||
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_unauthenticated_returns_401(): void
|
||||
{
|
||||
$response = $this->getJson("/api/v1/events/{$this->event->id}/persons/{$this->person->id}/field-values");
|
||||
$response = $this->getJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/persons/{$this->person->id}/field-values");
|
||||
|
||||
$response->assertUnauthorized();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user