Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude/rules/backend/team-access.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
20 changes: 19 additions & 1 deletion backend/resources/api-reference/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -10799,7 +10799,7 @@
}
}
},
"403": {
"409": {
"description": "",
"content": {
"application/json": {
Expand All @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
/>
);
}
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/common/StatusToggle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -141,7 +143,7 @@ const OrganizerStatusToggle = ({entityId, currentStatus, onSuccess}: {
return (
<StatusBanner
message={t`This organizer profile is not published yet`}
onPublish={handlePublish}
onPublish={canPublish ? handlePublish : undefined}
loading={mutation.isPending}
/>
);
Expand Down
19 changes: 11 additions & 8 deletions frontend/src/components/routes/event/SoldOutWaitlist/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -124,14 +125,16 @@ export const SoldOutWaitlist = () => {
</Group>
)}
>
<Button
color="green"
leftSection={<IconSend size={16}/>}
data-testid="waitlist-offer-next-button"
onClick={openOfferModal}
>
{t`Offer Tickets`}
</Button>
<WriteAccess>
<Button
color="green"
leftSection={<IconSend size={16}/>}
data-testid="waitlist-offer-next-button"
onClick={openOfferModal}
>
{t`Offer Tickets`}
</Button>
</WriteAccess>
</ToolBar>

{(!entries || !event) && <TableCardSkeleton rows={5}/>}
Expand Down
Loading