fix(auth): make last_sign_in_at stamp silent on sign-in - #59
Merged
Conversation
Production's sign-in stamps last_sign_in_at via a dedicated, silent updateWithSignIn path — a raw, debounced DB write that bypasses the event-emitting update() — so a login fires session.created alone. Emulate routed the stamp through ws.users.update, whose onUpdate hook fires user.updated on every login, diverging from real WorkOS and sending customers events that prod never emits. Closes #55
Greptile SummaryThis PR makes sign-in timestamp updates silent so routine logins no longer emit
Confidence Score: 5/5The PR appears safe to merge, with the silent timestamp path narrowly used and covered by authentication-event tests. The changed route preserves emitting updates for genuine email verification while suppressing only the production-compatible Important Files Changed
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
last_sign_in_atthroughws.users.update, whoseonUpdatehook fireduser.updatedon every login. Production writeslast_sign_in_atvia a dedicated, silentupdateWithSignInpath — a raw, debounced DB write that bypasses the event-emittingupdate()— so a real WorkOS sign-in emits onlysession.created.Collection.updateSilent(): updates and re-indexes a record without firingonUpdateor bumpingupdated_at, mirroring prod'supdateWithSignIn. Route the purelast_sign_in_atstamp through it.email_verifiedchange: a magic-auth sign-up still verifies the email via the emittingupdate()(oneuser.updated), matching production's email-verification path. Only the no-op repeat sign-in is now silent.user.updatedon a repeat sign-in (where onlylast_sign_in_atchanges) — that was the bug. It now expects none, matching the test's own stated intent ("repeat sign-in stays quiet").Closes #55