fix(qr): inactive answer for malformed codes, undated events, switched-off badge, reset-pending sessions

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
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-12-01 14:04:12 +08:00
1 parent c6c220265f
commit d532bdcda4
10 files changed
+59 -6

No files matched your search

@@ -138,7 +138,11 @@ public class PublicRegistrationService {
}
}
/** The gateway lets only this token shape through unsigned; anything else would come back 401 and surface as a 500. */
private static final java.util.regex.Pattern TOKEN_SHAPE = java.util.regex.Pattern.compile("[A-Za-z0-9_-]{22}");
private Open open(String token) {
if (token == null || !TOKEN_SHAPE.matcher(token).matches()) throw inactive();
Map<String, Object> link = found(() -> rest.getForEntity(url(RestApiCounterServiceConstants.API_REST_COUNTER_REGISTRATION_LINK_FIND_BY_TOKEN), MAP, token).getBody());
if (link == null || !Boolean.TRUE.equals(link.get("enabled")) || !(link.get("eventUuid") instanceof Number uuid)) throw inactive();
CompanyEvent e = found(() -> rest.getForEntity(url(RestApiCounterServiceConstants.API_REST_COUNTER_EVENT_FIND_BY_UUID), EVENT, uuid.longValue()).getBody());