From da4940292692d8a8405a246c0db771ee8a7d6500 Mon Sep 17 00:00:00 2001 From: max-1-max <201788345+max-1-max@users.noreply.github.com> Date: Fri, 27 Nov 2026 08:39:46 +0000 Subject: [PATCH 1/2] Close permission gaps found auditing v2.3.0 - An event settings PUT that omits allow_ticket_resale now counts as turning resale off, so members without ISSUE_REFUNDS can't switch it off by leaving the field out. - Hide the organizer profile Publish button from members who can't edit that organizer. - Hide the waitlist Offer Tickets button from read-only members. - Return 409 instead of a bare 403 when caption suggestions are unavailable, so the dashboard no longer sends the user to login. - Pass the event to the celebration modal after publishing from the draft banner, which crashed on render. --- .claude/rules/backend/team-access.md | 2 +- .../GenerateEventShareSuggestionsAction.php | 2 +- .../UpdateEventSettingsRequest.php | 2 +- .../EventShareSuggestionsActionTest.php | 4 ++-- .../TicketResale/TicketResaleSettingsTest.php | 16 ++++++++++++++++ .../common/StatusToggle/EventPublishFlow.tsx | 3 +-- .../components/common/StatusToggle/index.tsx | 4 +++- .../routes/event/SoldOutWaitlist/index.tsx | 19 +++++++++++-------- 8 files changed, 36 insertions(+), 16 deletions(-) diff --git a/.claude/rules/backend/team-access.md b/.claude/rules/backend/team-access.md index 9dae736bd2..74bf67424c 100644 --- a/.claude/rules/backend/team-access.md +++ b/.claude/rules/backend/team-access.md @@ -24,7 +24,7 @@ paths: - Treat any value that unlocks a public page as a credential. Staff responses return `orders.short_id` only to members with EDIT + VIEW_FINANCIALS; check-in list links are shareable with door staff on purpose. - Deliberate, don't "fix": VIEW_FINANCIALS hides money in the dashboard but doesn't stop an EDIT member from configuring outbound channels (organizer email, email templates, analytics pixels) or running the door, which shows door sales. - Free-text fields that tell buyers where to send money are payment settings. Changing an event's `offline_payment_instructions` needs MANAGE_PAYMENTS (Admins only by default) and a session: `UpdateEventSettingsRequest::after()` returns a 422 on the field for an API key or a member without it, on both PUT and PATCH. Re-sending the saved value (or one that purifies to it) always passes, so round-trips keep working; a PUT that omits it counts as clearing it. The payment settings form shows the instructions read-only to those members and re-sends the saved value. Same pattern as GTM containers in `PartialUpdateOrganizerSettingsRequest`. -- Turning ticket resale on or off (`allow_ticket_resale`, organizer `default_allow_ticket_resale`) needs ISSUE_REFUNDS, because resale refunds sellers from the organizer's Stripe account automatically. Same change-only check: re-sending the saved value passes, and both settings forms disable the switch for members without it. +- Turning ticket resale on or off (`allow_ticket_resale`, organizer `default_allow_ticket_resale`) needs ISSUE_REFUNDS, because resale refunds sellers from the organizer's Stripe account automatically. Same change-only check: re-sending the saved value passes, an event settings PUT that omits `allow_ticket_resale` counts as turning it off, and both settings forms disable the switch for members without it. - Public "same account" checks (draft previews, test orders, check-in staff view) use `AccountUserAccessService::currentMemberCanAccessEvent/Organizer`, never a raw account id comparison. - `AccountUserAccessService` caches access per request keyed by `AuthUserService::getAuthenticatedTokenKey()` (the JWT string, or `api-key:{id}` for API keys); never key it on decoded payload claims (resources call `isPermitted()` hundreds of times per list). - Frontend: 403s carrying `ACCESS_RESTRICTED`, `PERMISSION_REQUIRED` or `READ_ONLY_ROLE` must never send the user to login. diff --git a/backend/app/Http/Actions/Events/ShareSuggestions/GenerateEventShareSuggestionsAction.php b/backend/app/Http/Actions/Events/ShareSuggestions/GenerateEventShareSuggestionsAction.php index cd8b08940c..d3fe0788db 100644 --- a/backend/app/Http/Actions/Events/ShareSuggestions/GenerateEventShareSuggestionsAction.php +++ b/backend/app/Http/Actions/Events/ShareSuggestions/GenerateEventShareSuggestionsAction.php @@ -27,7 +27,7 @@ public function __invoke(int $eventId): JsonResponse } catch (ShareSuggestionsUnavailableException) { return $this->errorResponse( __('Caption suggestions are not available for this event.'), - ResponseCodes::HTTP_FORBIDDEN, + ResponseCodes::HTTP_CONFLICT, ); } catch (ShareSuggestionQuotaExceededException) { return $this->errorResponse( diff --git a/backend/app/Http/Request/EventSettings/UpdateEventSettingsRequest.php b/backend/app/Http/Request/EventSettings/UpdateEventSettingsRequest.php index 635ae95276..9044913e4e 100644 --- a/backend/app/Http/Request/EventSettings/UpdateEventSettingsRequest.php +++ b/backend/app/Http/Request/EventSettings/UpdateEventSettingsRequest.php @@ -204,7 +204,7 @@ private function offlinePaymentInstructionsChangeRefusal(): ?string private function changesTicketResale(): bool { - if (! $this->exists('allow_ticket_resale')) { + if (! $this->isMethod('PUT') && ! $this->exists('allow_ticket_resale')) { return false; } diff --git a/backend/tests/Feature/Http/Actions/Events/EventShareSuggestionsActionTest.php b/backend/tests/Feature/Http/Actions/Events/EventShareSuggestionsActionTest.php index a57a5ad94a..0c1a66c450 100644 --- a/backend/tests/Feature/Http/Actions/Events/EventShareSuggestionsActionTest.php +++ b/backend/tests/Feature/Http/Actions/Events/EventShareSuggestionsActionTest.php @@ -85,7 +85,7 @@ public function test_an_install_without_an_anthropic_key_reports_suggestions_as_ EventShareCaptionAgent::fake()->preventStrayPrompts(); $this->suggestions($this->owner)->assertOk()->assertJsonPath('data.availability', 'NOT_CONFIGURED'); - $this->generate($this->owner)->assertForbidden(); + $this->generate($this->owner)->assertStatus(409); } public function test_a_cloud_account_that_is_neither_verified_nor_connected_to_stripe_cannot_generate(): void @@ -94,7 +94,7 @@ public function test_a_cloud_account_that_is_neither_verified_nor_connected_to_s EventShareCaptionAgent::fake()->preventStrayPrompts(); $this->suggestions($this->owner)->assertOk()->assertJsonPath('data.availability', 'PAYMENTS_NOT_CONNECTED'); - $this->generate($this->owner)->assertForbidden(); + $this->generate($this->owner)->assertStatus(409); } public function test_an_account_that_has_used_its_daily_allowance_is_refused(): void diff --git a/backend/tests/Feature/Http/Actions/TicketResale/TicketResaleSettingsTest.php b/backend/tests/Feature/Http/Actions/TicketResale/TicketResaleSettingsTest.php index eea9a4fc64..7de4dc96fb 100644 --- a/backend/tests/Feature/Http/Actions/TicketResale/TicketResaleSettingsTest.php +++ b/backend/tests/Feature/Http/Actions/TicketResale/TicketResaleSettingsTest.php @@ -112,6 +112,22 @@ public function test_only_members_who_can_issue_refunds_can_turn_resale_on_or_of ->assertJsonValidationErrors(['allow_ticket_resale']); } + public function test_a_full_settings_save_without_resale_cannot_turn_it_off_for_a_member_who_cannot_issue_refunds(): void + { + $this->patchJson("/events/{$this->eventId}/settings", ['allow_ticket_resale' => true], $this->headers)->assertOk(); + $settings = $this->getJson("/events/{$this->eventId}/settings", $this->headers)->assertOk()->json('data'); + unset($settings['allow_ticket_resale']); + + $member = $this->addAccountUser($this->accountId); + $this->setPermissionOverrides($member, $this->accountId, ['ISSUE_REFUNDS' => false]); + + $this->forgetAuthenticatedUser(); + $this->putJson("/events/{$this->eventId}/settings", $settings, $this->headersFor($member, $this->accountId)) + ->assertJsonValidationErrors(['allow_ticket_resale']); + + $this->assertDatabaseHas('event_settings', ['event_id' => $this->eventId, 'allow_ticket_resale' => true]); + } + public function test_a_ticket_type_can_be_marked_as_not_resellable(): void { $payload = [ diff --git a/frontend/src/components/common/StatusToggle/EventPublishFlow.tsx b/frontend/src/components/common/StatusToggle/EventPublishFlow.tsx index bc724ade0b..66de5cea7f 100644 --- a/frontend/src/components/common/StatusToggle/EventPublishFlow.tsx +++ b/frontend/src/components/common/StatusToggle/EventPublishFlow.tsx @@ -26,8 +26,7 @@ export const EventPublishFlow = ({event, onPublished, onClose}: EventPublishFlow opened onClose={onClose} url={eventHomepageUrl(event)} - eventTitle={event.title} - eventId={String(event.id)} + event={event} /> ); } diff --git a/frontend/src/components/common/StatusToggle/index.tsx b/frontend/src/components/common/StatusToggle/index.tsx index 2d8e2d3871..6045df5049 100644 --- a/frontend/src/components/common/StatusToggle/index.tsx +++ b/frontend/src/components/common/StatusToggle/index.tsx @@ -116,6 +116,8 @@ const OrganizerStatusToggle = ({entityId, currentStatus, onSuccess}: { onSuccess?: () => void; }) => { const mutation = useUpdateOrganizerStatus(); + const {isLoaded, isReadOnly, canManageOrganizer} = useAccess(); + const canPublish = isLoaded && !isReadOnly && canManageOrganizer(entityId); const handlePublish = () => { confirmationDialog( @@ -141,7 +143,7 @@ const OrganizerStatusToggle = ({entityId, currentStatus, onSuccess}: { return ( ); diff --git a/frontend/src/components/routes/event/SoldOutWaitlist/index.tsx b/frontend/src/components/routes/event/SoldOutWaitlist/index.tsx index c6e334c198..7f770867cf 100644 --- a/frontend/src/components/routes/event/SoldOutWaitlist/index.tsx +++ b/frontend/src/components/routes/event/SoldOutWaitlist/index.tsx @@ -20,6 +20,7 @@ import {IconSend} from "@tabler/icons-react"; import {useGetEventOccurrences} from "../../../../queries/useGetEventOccurrences.ts"; import {OccurrenceSelect} from "../../../common/OccurrenceSelect"; import {SortSelector} from "../../../common/SortSelector"; +import {WriteAccess} from "../../../common/WriteAccess"; export const SoldOutWaitlist = () => { const {eventId} = useParams(); @@ -124,14 +125,16 @@ export const SoldOutWaitlist = () => { )} > - + + + {(!entries || !event) && } From a3c966d0dd35d4c17a36b01edb7f9e1511164e3a Mon Sep 17 00:00:00 2001 From: max-1-max <201788345+max-1-max@users.noreply.github.com> Date: Fri, 27 Nov 2026 09:20:24 +0000 Subject: [PATCH 2/2] Regenerate the API reference for the caption suggestions 409 --- backend/resources/api-reference/openapi.json | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/backend/resources/api-reference/openapi.json b/backend/resources/api-reference/openapi.json index 65b5cdd880..559c119f99 100644 --- a/backend/resources/api-reference/openapi.json +++ b/backend/resources/api-reference/openapi.json @@ -10799,7 +10799,7 @@ } } }, - "403": { + "409": { "description": "", "content": { "application/json": { @@ -10825,6 +10825,24 @@ "401": { "$ref": "#/components/responses/AuthenticationException" }, + "403": { + "description": "The authenticated user is not allowed to perform this action.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ] + } + } + } + }, "404": { "description": "The requested resource was not found.", "content": {