fix(tickets): staff scans skip the public ticket limit; order lookups for naming are rate-limited
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
This commit is contained in:
1 parent
051fca9a13
commit
02aa19a686
8 files changed
+49
-17
No files matched your search
@@ -51,7 +51,7 @@ Product design: `docs/superpowers/specs/2026-12-04-event-ticketing-design.md` (a
|
||||
- Normalisation and the `MOBILE_OR_EMAIL_REQUIRED`, name-length and email-format errors reuse the QR registration helpers in mobile-api.
|
||||
4. **Consent creates the lead through `RegistrationService.register`.** It is called with source `TICKET`, no salesperson, the company's current notice and `attend=false`. At check-in it is called with `attend=true`. The returned event lead uuid is stored on the ticket. An attendee whose details match a lead is linked to it, as QR registration already does.
|
||||
- **Unnamed tickets:** the consent needs a name and contact, so on the public page it is offered only for a named ticket. At the door, staff enter them first.
|
||||
5. **Staff view detection.** The `/t/[code]` page always loads the public view (`GET /api/public/tickets/{code}`). It also calls the portal's `/api/tickets/{code}`, which answers 401 at once when there is no session and otherwise calls `GET /api/admin/tickets/{code}`. That call is guarded by `@AdminModule("BO_EVENTS")` and scoped by company in mobile-api with `loadEvent(uuid, null)`, so another company's event is a 404. On 401, 403 or 404 the page stays public. The admin call uses a plain `fetch`, not `clientApi`, so a signed-out visitor is never bounced to login.
|
||||
5. **Staff view detection.** The `/t/[code]` page first calls the portal's `/api/tickets/{code}`, which answers 401 at once when there is no session and otherwise calls `GET /api/admin/tickets/{code}`. Only when that fails does it load the public view (`GET /api/public/tickets/{code}`), so a door scan never counts toward the public `tkt:load` limit. That call is guarded by `@AdminModule("BO_EVENTS")` and scoped by company in mobile-api with `loadEvent(uuid, null)`, so another company's event is a 404. On 401, 403 or 404 the page stays public. The admin call uses a plain `fetch`, not `clientApi`, so a signed-out visitor is never bounced to login.
|
||||
6. **Check-in.** `POST /api/admin/tickets/{code}/checkin` takes optional `{name, mobile, email, consent}`, which are required when the ticket is unnamed. Refusals are 409 with the codes `ALREADY_CHECKED_IN|<time>`, `NOT_VALID|<state>` and `NOT_EVENT_DAY`. The update is conditional (`checked_in_at IS NULL`), so two scanners cannot both check a ticket in; the loser gets `ALREADY_CHECKED_IN`. The action is `@Audited`.
|
||||
7. **Self check-in on a ticketed event.** For `tickets_enabled` events only, `EventCheckInService.lookup` checks, in order:
|
||||
1. the oldest `ACTIVE` ticket on a `PAID` order of the event, not checked in, whose attendee mobile or email matches, or whose attendee is blank and whose order's buyer mobile or email matches. It is checked in with `checked_in_by = 'self'`, and the lead is marked attended when the ticket has one;
|
||||
@@ -74,7 +74,7 @@ Product design: `docs/superpowers/specs/2026-12-04-event-ticketing-design.md` (a
|
||||
11. **Counts.** `EventHeadcountService.Headcount` gains `ticketsAwaiting`, `ticketsPaid` and `ticketsCheckedIn`, from one grouped query over active tickets joined to their order status. The portal's GuestsCard shows them when the event sells tickets.
|
||||
12. **Limits.**
|
||||
- `tkt:load:<ip>` allows 120 per 10 minutes, for the ticket page and the QR together.
|
||||
- `tkt:submit:<ip>:<event>` allows 60 per 10 minutes, for naming and consent.
|
||||
- `tkt:submit:<ip>:<event>` allows 60 per 10 minutes, for naming and consent. Naming first looks up the order by its token, which counts toward the order page's `ord:load:<ip>` limit (120 per 10 minutes).
|
||||
- Staff check-in has no IP limit: it is an authenticated admin call.
|
||||
|
||||
## Data
|
||||
@@ -101,7 +101,7 @@ ALTER TABLE `ticket`
|
||||
| counter | `POST ticket/attendee` (order token, ticket id, attendee, permission) | public via gateway |
|
||||
| counter | `POST ticket/consent` (code, notice id) | public via gateway |
|
||||
| counter | `POST ticket/staff` and `POST ticket/checkin` (company id and code in the body) | JWT (from mobile-api admin) |
|
||||
| counter | `POST ticketOrder/{id}/tickets/{ticketId}/resend` | JWT |
|
||||
| counter | `POST ticketOrder/resendTicket` (company, event, order and ticket ids in the body) | JWT |
|
||||
| mobile-api | `GET /api/public/tickets/{code}`, `GET .../qr.png`, `POST .../consent` | public |
|
||||
| mobile-api | `POST /api/public/orders/{token}/tickets/{ticketId}/attendee` | public |
|
||||
| mobile-api | `GET /api/admin/tickets/{code}`, `POST /api/admin/tickets/{code}/checkin` | `BO_EVENTS` |
|
||||
|
||||
Reference in new issue
Block a user