From 02aa19a6868048dd64f6257f59e8f2e32f13cccc Mon Sep 17 00:00:00 2001 From: ngqile Date: Fri, 4 Dec 2026 17:56:55 +0800 Subject: [PATCH] fix(tickets): staff scans skip the public ticket limit; order lookups for naming are rate-limited Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs --- openspec/changes/add-event-tickets/design.md | 6 ++-- .../app/lib/services/publicTickets.ts | 1 + .../app/t/[code]/page.test.tsx | 12 +++++++- solvway-admin-portal/app/t/[code]/page.tsx | 28 +++++++++++-------- .../api/service/AdminTicketService.java | 3 ++ .../api/service/PublicTicketService.java | 3 ++ .../api/service/AdminTicketCheckInTest.java | 5 +++- .../api/service/PublicTicketPageTest.java | 8 ++++++ 8 files changed, 49 insertions(+), 17 deletions(-) diff --git a/openspec/changes/add-event-tickets/design.md b/openspec/changes/add-event-tickets/design.md index 378cea1..e4de9e6 100644 --- a/openspec/changes/add-event-tickets/design.md +++ b/openspec/changes/add-event-tickets/design.md @@ -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|