fix: address final review of event invitations
Mask invite, check-in and registration-link tokens in gateway logs. Audit the attended flag only when it really changes. Drop a salesperson who left the event team from invite registrations. Answer 404 for check-in by guest on a disabled event. Deployment notes and the release-check record updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
1 parent
c4183facf6
commit
2af360c775
12 files changed
+74
-11
No files matched your search
+3
-3
@@ -123,7 +123,7 @@ Run it when the new services-system and mobile-api go live. Staff who are signed
|
||||
| `openspec/changes/archive/2026-12-01-add-event-invitations/sql/01-event-guests.sql` | Creates `service-counter`.`event_guest` (each event's invitation list), adds `capacity`, `invitation_cap` and `checkin_token` to `event`, and `attended_at` to `event_lead`. DDL. |
|
||||
| `openspec/changes/archive/2026-12-01-add-event-invitations/sql/02-event-guests-module.sql` | Adds the Event guests back-office module (`BO_EVENT_GUESTS`). No role gets it; super admins grant it under Roles. |
|
||||
|
||||
Run both, in order, before the new images go live: the new services-counter reads the new columns on every event and event lead query and fails without them. `01` needs a user that may alter tables. `99-rollback.sql` in the same folder undoes them and deletes the guest lists and attendance times.
|
||||
Run both, in order, before the new images go live: the new services-counter reads the new columns on every event and event lead query and fails without them. `01` needs a user that may alter tables. If `01` stops partway, check which columns already exist before running it again: only its `CREATE TABLE` is safe to repeat. `99-rollback.sql` in the same folder undoes them and deletes the guest lists and attendance times.
|
||||
|
||||
**Review the privacy notice before go-live.** The seeded text is a starting template written for the PDPA, not legal advice. INS and CV should each have theirs checked; a super admin changes it under **Companies → Privacy notice**. A company with no notice has no working QR codes.
|
||||
|
||||
@@ -205,7 +205,7 @@ The keys:
|
||||
| `AUTH_API_KEYS` | Secret | The keys mobile-api accepts from its clients, comma-separated, each `<key>:APP`. The admin portal's `MOBILE_API_KEY` must be one of them. |
|
||||
| `JWT_SECRET` | Secret | Same value as `JWT_TOKEN` |
|
||||
| `CUSTOMER_PORTAL_BASE_URL` | Plain | The customer portal is not deployed in phase 1. When unset, it falls back to a Tastefully address that only the member referral link uses, which Co-Lite does not use. Set it once a customer portal exists. |
|
||||
| `ADMIN_PORTAL_BASE_URL` | Plain | Required. The public address of the admin portal, with no trailing slash (for example `https://admin.example.com`). Invite emails and copied invite links point at `<this>/i/<token>`, and check-in codes at `<this>/c/<token>`. mobile-api does not start without it. |
|
||||
| `ADMIN_PORTAL_BASE_URL` | Plain | Required. The public address of the admin portal, with no trailing slash (for example `https://admin.example.com`). Invite emails link to `<this>/i/<token>`. Links that staff copy or print in the portal (guest links, event and personal codes, the check-in code) use the address the staff member has open, so keep the two the same. mobile-api does not start without it. |
|
||||
|
||||
**`service-log`:**
|
||||
|
||||
@@ -328,7 +328,7 @@ data:
|
||||
- **Companies and super admins.** INS and CV each see only their own leads, events, event leads, users, emails, login history and audit log. Staff sign in with their company code, username and password. A super admin leaves Company blank, sees every company (with a company picker in the header), and is the only one who can manage companies, roles, interests, lockout settings and password rules. Changing a company's code renames its staff's sign-in names and signs them out; deactivating a company blocks its staff from signing in. Emails sent from public forms and other system emails have no company, so only super admins see them. Do not give a company's old code to another company while sessions opened under the old code may still be valid: such a session token would resolve to the new company's user of the same name. When in doubt, never reuse a code.
|
||||
- **Lead dashboard.** Users whose role has the Dashboard module see lead captures, wins, conversion and overdue follow-ups on the home page, for this month, last month or a custom range of up to two years in Malaysian time. A lead counts as converted when its status at an event is WON. Wins and days to win come from the status history, which starts with this release; for older leads it is approximate (see section 3).
|
||||
- **QR self-registration.** Visitors scan a code and register themselves as a lead at an event. Each event has an event code, and each team member has a personal code that assigns the visitor to them; staff with Events see and switch them off on the event page, and every staff user finds their own under **My QR codes** in the user menu. Codes work until the event's end date (Malaysian time). A registration never edits an existing lead: differences go into that event lead's notes for staff to check. Each visitor IP may load 120 registration pages in 10 minutes across all events, and submit 60 registrations per event in 10 minutes; there is no CAPTCHA. For a reprintable code with scan counts, paste the code's link into the dynamic-qr console and print that code instead; no visitor data reaches dynamic-qr.
|
||||
- **Invitations and check-in.** Staff with **Event guests** add guests to an event (one by one or by pasting a list), set the event's capacity and invitation cap, and send invitations. Without an email provider, a sent invitation is only saved under **Emails**; staff copy each guest's link (or "Copy all links") and send it themselves. A guest registers through their own link (`/i/<token>`) and checks in at the door by the event's check-in code (`/c/<token>`), by mobile or email, or as a walk-in. Before the event, registration stops at capacity; on the event days nobody is refused. Staff with Events see the guest list read-only and the invited, registered, attended and walk-in numbers. Grant Event guests to the office admins who run invitations; it is a permission only, with no menu entry of its own.
|
||||
- **Invitations and check-in.** Staff with **Event guests** add guests to an event (one by one or by pasting a list), set the event's capacity and invitation cap, and send invitations. Without an email provider, a sent invitation is only saved under **Emails**; staff copy each guest's link and send it themselves. A guest registers through their own link (`/i/<token>`) and checks in at the door by the event's check-in code (`/c/<token>`), by mobile or email, or as a walk-in. Before the event, registration stops at capacity; on the event days nobody is refused. Staff with Events see the guest list read-only and the invited, registered, attended and walk-in numbers. Grant Event guests to the office admins who run invitations, together with Events (the guest actions need both); it is a permission only, with no menu entry of its own. Door check-in allows 300 lookups and walk-in registrations per visitor IP per event in 10 minutes; a large event where every visitor shares one venue Wi-Fi address can reach that, so ask visitors to use mobile data if check-ins start to be refused.
|
||||
- **Error codes between services.** services-counter answers a refused request (for example `EVENT_FULL`) with a ProblemDetail whose `detail` is the reason code; mobile-api reads the code from there. Keep the core error handler in services-counter as it is.
|
||||
- **Email sender.** services-email fills in its default sender when a request has none. Override the default sender address as in section 6 before email delivery is switched on.
|
||||
- **Gateway paths open to the public registration.** The internal gateway lets a few exact read paths and the registration write through without a user token, so mobile-api can serve visitors who are not signed in. The invitations release adds five more, each an exact method and path: `GET /counter/eventGuest/findByToken/<22-character token>`, `POST /counter/eventGuest/register`, `GET /counter/checkin/findEvent/<22-character token>`, `POST /counter/checkin/lookup` and `POST /counter/checkin/byGuest`. Keep the gateway unexposed (above); the design notes in the change folder list the paths and the risk.
|
||||
|
||||
@@ -195,7 +195,7 @@ Every portal verify must report the exit codes of lint, tsc and vitest. Vitest e
|
||||
- an invite email is saved under Emails;
|
||||
- the audit targets.
|
||||
- Backend part done 2026-12-01 on the local stack (API only): guests add/paste/duplicate/cap, cap below guests, send (emails saved with link and BM), invite register and link check-in, door check-in for a registered guest, an invited non-registered guest and an unknown walk-in, event full before the event, registered guest not removable, check-in not yet, numbers equal to a direct DB count, audit targets. It found and fixed four bugs (unlinked guest list, counter ProblemDetail codes, null email sender, invite registration marking attendance). The portal part remains.
|
||||
- Portal part done 2026-12-01 on the local stack: invite page (open with prefilled form, consent required, already checked in), check-in page (open, lookup to a blank walk-in form, not yet, inactive), event page Guests section with numbers matching the API (3 invited, 3 registered, 4 attended, 1 walk-in, capacity 4), print cards, event leads Attended filter; `attended=true/false` checked against the database. My QR share and full screen were not driven in a browser (no staff sign-in available locally; covered by unit tests).
|
||||
- Portal part done 2026-12-01 on the local stack: invite page (open with prefilled form, consent required, already checked in), check-in page (open, lookup to a blank walk-in form, not yet, inactive), event page Guests section with numbers matching the API (3 invited, 3 registered, 4 attended, 1 walk-in, capacity 4), print cards, event leads Attended filter; `attended=true/false` checked against the database. My QR at 360 px driven with a throwaway CV staff user (temporarily on the event team, then removed and disabled): the new-code notice shows, Share falls back to copying the link when the browser has no share sheet, and Show full screen opens a large QR dialog that Close or Escape dismisses. The native share sheet itself was not exercised (headless browser has none).
|
||||
- **Playwright at 1280 and 360 px:** the invite page, the check-in page (all states), the Guests section, the print page, and My QR codes share and full screen.
|
||||
- Scope: `docs/deployment.md`, `openspec/changes/add-event-invitations/tasks.md`
|
||||
- Verify: the four Maven modules and the portal verify.
|
||||
|
||||
@@ -37,9 +37,21 @@ final class LogRedactor {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** The path with JWT-shaped segments (e.g. /auth/findUserByToken/M/<jwt>) masked. */
|
||||
/** Path prefixes followed by a bearer-style invite, check-in or registration-link token. */
|
||||
private static final List<String> TOKEN_PREFIXES = List.of("/counter/eventGuest/findByToken/", "/counter/checkin/findEvent/",
|
||||
"/counter/registrationLink/findByToken/");
|
||||
|
||||
/** The path with JWT-shaped segments (e.g. /auth/findUserByToken/M/<jwt>) and invite/check-in tokens masked. */
|
||||
static String path(String path) {
|
||||
if (path == null || !path.contains("eyJ")) {
|
||||
if (path == null) {
|
||||
return path;
|
||||
}
|
||||
for (String prefix : TOKEN_PREFIXES) {
|
||||
if (path.startsWith(prefix)) {
|
||||
return prefix + MASK;
|
||||
}
|
||||
}
|
||||
if (!path.contains("eyJ")) {
|
||||
return path;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(path.length());
|
||||
|
||||
@@ -42,6 +42,16 @@ class LogRedactorTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("path: invite and check-in tokens are masked, unrelated paths kept")
|
||||
void pathEventTokensMasked() {
|
||||
String token = "AbCdEfGhIjKlMnOpQrSt-_";
|
||||
assertThat(LogRedactor.path("/counter/eventGuest/findByToken/" + token)).isEqualTo("/counter/eventGuest/findByToken/***");
|
||||
assertThat(LogRedactor.path("/counter/checkin/findEvent/" + token)).isEqualTo("/counter/checkin/findEvent/***");
|
||||
assertThat(LogRedactor.path("/counter/registrationLink/findByToken/" + token)).isEqualTo("/counter/registrationLink/findByToken/***");
|
||||
assertThat(LogRedactor.path("/counter/event/findByUuid/123")).isEqualTo("/counter/event/findByUuid/123");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("path: JWT-shaped segments are masked, other segments kept")
|
||||
void pathJwtMasked() {
|
||||
|
||||
+1
@@ -151,6 +151,7 @@ public class AdminEventGuestService {
|
||||
throw AdminEventLeadService.required(List.of("guestIds"));
|
||||
}
|
||||
Set<Long> wanted = allUnsent ? Set.of() : new HashSet<>(r.guestIds());
|
||||
// ponytail: one synchronous email call per guest inside the request; fine at current sizes, move to async/batched above ~500 guests.
|
||||
List<Long> sentIds = new ArrayList<>();
|
||||
int skippedNoEmail = 0;
|
||||
try {
|
||||
|
||||
+1
-1
@@ -289,7 +289,7 @@ public class AdminEventLeadService {
|
||||
if (!new HashSet<>(interestIds).equals(new HashSet<>(longs(current.get("interestIds"))))) changed.add("interestIds");
|
||||
if (!Objects.equals(body.get("nextFollowUpDate"), current.get("nextFollowUpDate") == null ? null : current.get("nextFollowUpDate").toString())) changed.add("nextFollowUpDate");
|
||||
if (!Objects.equals(body.get("notes"), current.get("notes"))) changed.add("notes");
|
||||
if (r.attended() != null && !r.attended().equals(current.get("attended"))) changed.add("attended");
|
||||
if (r.attended() != null && !r.attended().equals(current.get("attendedAt") != null)) changed.add("attended");
|
||||
if (!changed.isEmpty()) AuditChanges.fields(changed.toArray(String[]::new));
|
||||
return view(saved, known, new HashMap<>());
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
app:
|
||||
api-key: ${APIKEY:}
|
||||
api-gateway-url: ${APIGATEWAYURL}
|
||||
# TODO: confirm real customer-portal host
|
||||
# Required outside the local profile (no default): invitation emails link to <this>/i/<token>.
|
||||
admin-portal-base-url: ${ADMIN_PORTAL_BASE_URL}
|
||||
# TODO: confirm real customer-portal host
|
||||
customer-portal-base-url: ${CUSTOMER_PORTAL_BASE_URL:https://user.tastefullyexpo.com}
|
||||
system:
|
||||
format:
|
||||
|
||||
+13
-1
@@ -36,6 +36,7 @@ class AdminEventLeadServiceAuditChangesTest {
|
||||
private RestTemplateCustomUtil rest;
|
||||
private AdminEventLeadService service;
|
||||
private MockedStatic<HttpReqRespUtils> http;
|
||||
private final Map<String, Object> detail = new LinkedHashMap<>();
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
@@ -61,7 +62,7 @@ class AdminEventLeadServiceAuditChangesTest {
|
||||
.thenReturn(ResponseEntity.ok(List.of(
|
||||
Map.of("id", 3L, "companyId", COMPANY, "name", "Cookware", "active", true, "sortOrder", 0),
|
||||
Map.of("id", 4L, "companyId", COMPANY, "name", "Kitchen", "active", true, "sortOrder", 0))));
|
||||
Map<String, Object> d = new LinkedHashMap<>();
|
||||
Map<String, Object> d = detail;
|
||||
d.put("eventLeadUuid", EL);
|
||||
d.put("companyId", COMPANY);
|
||||
d.put("eventUuid", EV);
|
||||
@@ -98,6 +99,17 @@ class AdminEventLeadServiceAuditChangesTest {
|
||||
assertThat(json).doesNotContain("private call note", "old note", "HOT", "2027-01-20");
|
||||
}
|
||||
|
||||
@Test
|
||||
void update_attendedEqualToCurrentStateIsNotAudited() {
|
||||
detail.put("attendedAt", "2027-01-20T10:00:00");
|
||||
|
||||
update(new AdminEventLeadUpdateRequest(21L, "WARM", "OPEN", List.of(3L), "2027-01-20", "old note", true));
|
||||
assertThat(AuditChanges.current()).isNull();
|
||||
|
||||
update(new AdminEventLeadUpdateRequest(21L, "WARM", "OPEN", List.of(3L), "2027-01-20", "old note", false));
|
||||
assertThat((List<String>) AuditChanges.current().get("fields")).containsExactly("attended");
|
||||
}
|
||||
|
||||
@Test
|
||||
void update_nothingChangedRecordsNothing() {
|
||||
update(new AdminEventLeadUpdateRequest(21L, "WARM", "OPEN", List.of(3L), "2027-01-20", "old note"));
|
||||
|
||||
+3
-1
@@ -95,7 +95,9 @@ public class EventCheckInService {
|
||||
.filter(x -> company == x.getCompanyId())
|
||||
.orElseThrow(() -> notFound("GUEST_NOT_FOUND"));
|
||||
if (g.getEventLeadId() == null) throw new ResponseStatusException(HttpStatus.CONFLICT, "NOT_REGISTERED");
|
||||
if (!EventDays.isDuring(event(g.getCompanyId(), g.getEventUuid()), LocalDateTime.now())) {
|
||||
Event event = event(g.getCompanyId(), g.getEventUuid());
|
||||
if (event.getEnabled() != GeneralEnum.FlagYesNo.Y) throw notFound("EVENT_NOT_FOUND");
|
||||
if (!EventDays.isDuring(event, LocalDateTime.now())) {
|
||||
throw new ResponseStatusException(HttpStatus.CONFLICT, "NOT_EVENT_DAY");
|
||||
}
|
||||
EventLead el = eventLeadRepository.findById(g.getEventLeadId()).orElseThrow(() -> notFound("GUEST_NOT_FOUND"));
|
||||
|
||||
+5
-1
@@ -194,8 +194,12 @@ public class EventGuestService {
|
||||
+ eventLeadRepository.countWalkIns(g.getEventUuid()) >= event.getCapacity()) {
|
||||
throw new ResponseStatusException(HttpStatus.CONFLICT, "EVENT_FULL");
|
||||
}
|
||||
Long stored = g.getSalespersonUserId();
|
||||
// null when the salesperson is no longer on the event team
|
||||
Long salesperson = stored != null && eventSalespersonRepository.findByEventUuid(g.getEventUuid()).stream()
|
||||
.anyMatch(s -> s.getUserId() == stored) ? stored : null;
|
||||
return registrationService.register(new RegistrationService.RegisterRequest(g.getCompanyId(), g.getEventUuid(),
|
||||
g.getSalespersonUserId(), req.name(), req.mobileE164(), req.email(), req.companyName(), req.jobTitle(),
|
||||
salesperson, req.name(), req.mobileE164(), req.email(), req.companyName(), req.jobTitle(),
|
||||
req.interestIds(), req.consentNoticeId(), req.consentAt(), false, "INVITE", g.getId()));
|
||||
}
|
||||
}
|
||||
+10
@@ -242,6 +242,16 @@ class EventCheckInServiceTest {
|
||||
.satisfies(t -> assertStatus(t, HttpStatus.CONFLICT, "NOT_REGISTERED"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void byGuestIs404WhenTheEventIsDisabled() {
|
||||
guest(9L);
|
||||
event.setEnabled(com.solvway.core.enums.GeneralEnum.FlagYesNo.N);
|
||||
|
||||
assertThatThrownBy(() -> service.byGuest(new EventCheckInService.ByGuestRequest(COMPANY, "gt")))
|
||||
.satisfies(t -> assertStatus(t, HttpStatus.NOT_FOUND, "EVENT_NOT_FOUND"));
|
||||
verify(eventLeadRepository, never()).save(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void byGuestRefusesOutsideTheEventDays() {
|
||||
guest(9L);
|
||||
|
||||
+12
@@ -352,6 +352,18 @@ class EventGuestServiceTest {
|
||||
assertThat(q.interestIds()).containsExactly(3L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerDropsTheSalespersonWhoLeftTheEventTeam() {
|
||||
registrable().setSalespersonUserId(99L);
|
||||
when(registrationService.register(any())).thenReturn(new RegistrationService.RegisterResult("CREATED", "555"));
|
||||
|
||||
service.register(reg());
|
||||
|
||||
ArgumentCaptor<RegistrationService.RegisterRequest> c = ArgumentCaptor.forClass(RegistrationService.RegisterRequest.class);
|
||||
verify(registrationService).register(c.capture());
|
||||
assertThat(c.getValue().salespersonUserId()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerIs404ForAnotherCompanysGuest() {
|
||||
EventGuest g = registrable();
|
||||
|
||||
Reference in new issue
Block a user