Fix revoke race returning stale approved status and clear last_seen_at on re-register

Bug 1: In client-approval mode, when markSeen returns None (because the
client was revoked/rejected between upsert and markSeen), the fallback
incorrectly returned status 'approved'. Now returns 'rejected' to prevent
credential minting for revoked/rejected clients.

Bug 2: The upsert conflict path for revoked clients cleared status,
approved_at, rejected_at, and revoked_at but never cleared last_seen_at,
causing stale 'Last connected' times after re-registration. Now resets
last_seen_at to NULL when a revoked client re-registers.
This commit is contained in:
Cursor Agent committed 2026-06-27 14:35:28 +00:00
1 parent 4f4335b7f7
commit 87ff841023
2 files changed
+5 -1

No files matched your search

+1 -1
View File
@@ -333,7 +333,7 @@ export const make = Effect.gen(function* () {
return { mode, status: "approved" as const, client: seenClient };
}
return { mode, status: "approved" as const, client: visibleClient };
return { mode, status: "rejected" as const, client: visibleClient };
});
const updateDecision = <E extends ConnectClientApprovalError | ConnectClientRejectionError>(
@@ -256,6 +256,10 @@ export const make = Effect.gen(function* () {
WHEN auth_connect_clients.revoked_at IS NULL THEN auth_connect_clients.rejected_at
ELSE NULL
END,
last_seen_at = CASE
WHEN auth_connect_clients.revoked_at IS NULL THEN auth_connect_clients.last_seen_at
ELSE NULL
END,
revoked_at = NULL
RETURNING ${sql.unsafe(rowSelection)}
`,