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

@@ -21,26 +21,26 @@ interface PaginatedResponse<T> {
}
}
export function useCrowdLists(eventId: Ref<string>) {
export function useCrowdLists(orgId: Ref<string>, eventId: Ref<string>) {
return useQuery({
queryKey: ['crowd-lists', eventId],
queryFn: async () => {
const { data } = await apiClient.get<{ data: CrowdList[] }>(
`/events/${eventId.value}/crowd-lists`,
`/organisations/${orgId.value}/events/${eventId.value}/crowd-lists`,
)
return data.data
},
enabled: () => !!eventId.value,
enabled: () => !!orgId.value && !!eventId.value,
})
}
export function useCrowdListPersons(eventId: Ref<string>, crowdListId: Ref<string>) {
export function useCrowdListPersons(orgId: Ref<string>, eventId: Ref<string>, crowdListId: Ref<string>) {
return useQuery({
queryKey: ['crowd-lists', eventId, 'persons', crowdListId],
queryFn: async () => {
const { data } = await apiClient.get<PaginatedResponse<Person>>(
`/events/${eventId.value}/crowd-lists/${crowdListId.value}/persons`,
`/organisations/${orgId.value}/events/${eventId.value}/crowd-lists/${crowdListId.value}/persons`,
)
return data
@@ -49,13 +49,13 @@ export function useCrowdListPersons(eventId: Ref<string>, crowdListId: Ref<strin
})
}
export function useCreateCrowdList(eventId: Ref<string>) {
export function useCreateCrowdList(orgId: Ref<string>, eventId: Ref<string>) {
const queryClient = useQueryClient()
return useMutation({
mutationFn: async (payload: CreateCrowdListDto) => {
const { data } = await apiClient.post<ApiResponse<CrowdList>>(
`/events/${eventId.value}/crowd-lists`,
`/organisations/${orgId.value}/events/${eventId.value}/crowd-lists`,
payload,
)
@@ -67,13 +67,13 @@ export function useCreateCrowdList(eventId: Ref<string>) {
})
}
export function useUpdateCrowdList(eventId: Ref<string>) {
export function useUpdateCrowdList(orgId: Ref<string>, eventId: Ref<string>) {
const queryClient = useQueryClient()
return useMutation({
mutationFn: async ({ id, ...payload }: UpdateCrowdListDto & { id: string }) => {
const { data } = await apiClient.put<ApiResponse<CrowdList>>(
`/events/${eventId.value}/crowd-lists/${id}`,
`/organisations/${orgId.value}/events/${eventId.value}/crowd-lists/${id}`,
payload,
)
@@ -85,12 +85,12 @@ export function useUpdateCrowdList(eventId: Ref<string>) {
})
}
export function useDeleteCrowdList(eventId: Ref<string>) {
export function useDeleteCrowdList(orgId: Ref<string>, eventId: Ref<string>) {
const queryClient = useQueryClient()
return useMutation({
mutationFn: async (id: string) => {
await apiClient.delete(`/events/${eventId.value}/crowd-lists/${id}`)
await apiClient.delete(`/organisations/${orgId.value}/events/${eventId.value}/crowd-lists/${id}`)
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['crowd-lists', eventId.value] })
@@ -98,13 +98,13 @@ export function useDeleteCrowdList(eventId: Ref<string>) {
})
}
export function useAddPersonToCrowdList(eventId: Ref<string>) {
export function useAddPersonToCrowdList(orgId: Ref<string>, eventId: Ref<string>) {
const queryClient = useQueryClient()
return useMutation({
mutationFn: async ({ listId, personId }: { listId: string; personId: string }) => {
const { data } = await apiClient.post<ApiResponse<CrowdList>>(
`/events/${eventId.value}/crowd-lists/${listId}/persons`,
`/organisations/${orgId.value}/events/${eventId.value}/crowd-lists/${listId}/persons`,
{ person_id: personId },
)
@@ -116,13 +116,13 @@ export function useAddPersonToCrowdList(eventId: Ref<string>) {
})
}
export function useRemovePersonFromCrowdList(eventId: Ref<string>) {
export function useRemovePersonFromCrowdList(orgId: Ref<string>, eventId: Ref<string>) {
const queryClient = useQueryClient()
return useMutation({
mutationFn: async ({ listId, personId }: { listId: string; personId: string }) => {
await apiClient.delete(
`/events/${eventId.value}/crowd-lists/${listId}/persons/${personId}`,
`/organisations/${orgId.value}/events/${eventId.value}/crowd-lists/${listId}/persons/${personId}`,
)
},
onSuccess: (_data, variables) => {
@@ -134,7 +134,7 @@ export function useRemovePersonFromCrowdList(eventId: Ref<string>) {
})
}
export function useApproveAllPending(eventId: Ref<string>) {
export function useApproveAllPending(orgId: Ref<string>, eventId: Ref<string>) {
const queryClient = useQueryClient()
return useMutation({
@@ -142,7 +142,7 @@ export function useApproveAllPending(eventId: Ref<string>) {
const results = await Promise.allSettled(
personIds.map(id =>
apiClient.post<ApiResponse<Person>>(
`/events/${eventId.value}/persons/${id}/approve`,
`/organisations/${orgId.value}/events/${eventId.value}/persons/${id}/approve`,
),
),
)