feat: QR self-registration for walk-in visitors #31

Merged
ngqile merged 20 commits from add-qr-self-registration into main 2026-12-01 06:11:05 +00:00
Owner

Implements OpenSpec change add-qr-self-registration (design: docs/superpowers/specs/2026-12-01-qr-self-registration-design.md).

What it does

  • Walk-in visitors scan a QR code and register themselves as a lead on a public page, /r/<code>, served by the admin portal. The page shows the event's name, dates and location, a short form, and the company's privacy notice in English and Bahasa Malaysia with a required consent tick box.
  • Each event has an event code. Each team member has a personal code that assigns the visitor to them, provided they are still an active member of the team.
  • A matched lead is never edited. Mobile is matched first, then email. Any differing values go into the event lead's notes. Someone already captured at the event changes nothing, except that an unassigned capture gets the personal code's salesperson.
  • Every visitor gets the same thank-you page, so the page never reveals whether a person exists. Every unusable code gets the same "no longer active" answer.
  • Abuse limits:
    • 120 page loads per IP per 10 minutes;
    • 60 submissions per IP per event per 10 minutes;
    • a honeypot field.
      The IP is the last X-Forwarded-For hop.
  • Staff tools:
    • the event page has a Registration QR card: QR image, copy link, PNG download, and an on/off switch;
    • My QR codes in the user menu;
    • super admins get a versioned privacy-notice editor on Companies.
  • Consent is recorded per event lead (consent_at, consent_notice_id), and the source is stored as STAFF or QR.
  • The internal gateway now lets the public flow's exact method and path pairs through without a user token.
    • /user/findById stays closed, and a yes/no activeAdminOf endpoint replaces it for this check.
    • The risks are noted in design.md.

Database

Run sql/01-registration-link.sql and then sql/02-company-privacy-notice.sql before the new images go live (DDL; see docs/deployment.md). 99-rollback.sql undoes both. The default notice is a template and must be reviewed by INS and CV.

Verification

  • mvn -T 1C -B -q verify: exit 0.
  • Portal npm run lint, npx tsc --noEmit, npx vitest run: all exit 0 (206 files, 1423 tests).
  • Every task passed an Opus review gate, and a whole-branch Opus review followed. Its findings are fixed or recorded as accepted risks.
  • Live on the local stack:
    • event code and personal code;
    • a new person, a known person at another event (EXISTING with notes, lead unchanged), and an already-captured person (assigned);
    • consent and missing-contact errors, the honeypot, unknown, malformed and switched-off codes, and the 429 on the 121st load;
    • the audit log records the event uuid, never the code.
  • Playwright:
    • the public page at 360 px: form, consent error, thank-you and reset, inactive, too many;
    • the event QR card at 1280 px, including the switch;
    • My QR codes for a salesperson at 360 px;
    • the privacy notice editor (save and error).

🤖 Generated with Claude Code

https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM

Implements OpenSpec change `add-qr-self-registration` (design: `docs/superpowers/specs/2026-12-01-qr-self-registration-design.md`). ## What it does - Walk-in visitors scan a QR code and register themselves as a lead on a public page, `/r/<code>`, served by the admin portal. The page shows the event's name, dates and location, a short form, and the company's privacy notice in English and Bahasa Malaysia with a required consent tick box. - Each event has an event code. Each team member has a personal code that assigns the visitor to them, provided they are still an active member of the team. - A matched lead is never edited. Mobile is matched first, then email. Any differing values go into the event lead's notes. Someone already captured at the event changes nothing, except that an unassigned capture gets the personal code's salesperson. - Every visitor gets the same thank-you page, so the page never reveals whether a person exists. Every unusable code gets the same "no longer active" answer. - Abuse limits: - 120 page loads per IP per 10 minutes; - 60 submissions per IP per event per 10 minutes; - a honeypot field. The IP is the last `X-Forwarded-For` hop. - Staff tools: - the event page has a Registration QR card: QR image, copy link, PNG download, and an on/off switch; - **My QR codes** in the user menu; - super admins get a versioned privacy-notice editor on Companies. - Consent is recorded per event lead (`consent_at`, `consent_notice_id`), and the source is stored as `STAFF` or `QR`. - The internal gateway now lets the public flow's exact method and path pairs through without a user token. - `/user/findById` stays closed, and a yes/no `activeAdminOf` endpoint replaces it for this check. - The risks are noted in design.md. ## Database Run `sql/01-registration-link.sql` and then `sql/02-company-privacy-notice.sql` before the new images go live (DDL; see `docs/deployment.md`). `99-rollback.sql` undoes both. The default notice is a template and must be reviewed by INS and CV. ## Verification - `mvn -T 1C -B -q verify`: exit 0. - Portal `npm run lint`, `npx tsc --noEmit`, `npx vitest run`: all exit 0 (206 files, 1423 tests). - Every task passed an Opus review gate, and a whole-branch Opus review followed. Its findings are fixed or recorded as accepted risks. - Live on the local stack: - event code and personal code; - a new person, a known person at another event (EXISTING with notes, lead unchanged), and an already-captured person (assigned); - consent and missing-contact errors, the honeypot, unknown, malformed and switched-off codes, and the 429 on the 121st load; - the audit log records the event uuid, never the code. - Playwright: - the public page at 360 px: form, consent error, thank-you and reset, inactive, too many; - the event QR card at 1280 px, including the switch; - My QR codes for a salesperson at 360 px; - the privacy notice editor (save and error). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
ngqile added 20 commits 2026-12-01 06:10:54 +00:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Registration links (event code and personal codes, oldest wins on a
duplicate), lookup by token, the caller's own codes, and the capture that
matches by mobile then email, never edits a matched lead, and records the
source and consent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
GET and POST /company/{id}/privacyNotice: the newest row is current and
saving always adds a version, so consent records keep pointing at the
text the visitor saw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Public page and submit for a registration code (one 404 for every unusable
code, load and submit limits, honeypot, consent), event and own codes for
staff, the switch audited against the event uuid rather than the token,
and the super-admin privacy-notice endpoints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
A visitor has no user token, so the gateway refused every call the public
page makes. Open only the exact method and path pairs it needs, and replace
the full user lookup with a yes/no activeAdminOf endpoint so no user record
is exposed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
The public /r/<code> page (no admin shell, never redirects a visitor to the
staff login), its proxy sending only the last X-Forwarded-For hop, the event
page's Registration QR card, a My QR codes page in the user menu, and the
super-admin privacy notice editor on Companies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
The services write local Malaysian time, but the seed used the server clock
(UTC), so the editor showed the default notice eight hours early.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Member codes on the event page are labelled "name (username)", as in the
team list, and the consent tick box reads in English and Bahasa Malaysia.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
A code of the wrong shape now shows "no longer active" instead of failing,
My QR codes skips events with no end date and marks switched-off codes,
and a session waiting on a password reset can still open a QR page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
ngqile merged commit 03b85737d7 into main 2026-12-01 06:11:05 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ngqile/co-lite#31