Repository navigation
fix(auth): idempotent email verification links - #3
Merged
Merged
Conversation
Verifying an email with a link that was already used returned the generic 'Invalid or expired verification token' error, which looks like a broken account to the user (typical case: double click, or the mail client prefetching the link). The verification token now carries an HMAC marker (vmk) bound to the account's current email_verified_at. verifyEmailToken returns a typed result (verified / already_verified / invalid): - account unverified -> verify and return the new session - already verified + marker matches -> already_verified, still issue a fresh session instead of an error - stale/superseded token or expired -> invalid (400 as before) - concurrent clicks: the loser re-checks and resolves as already_verified Tokens issued before this change have no marker and keep working while the account is unverified and the JWT has not expired. Route returns alreadyVerified; frontend shows a friendly message and logs the user in (ES/EN strings added).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Verifying an email with a link that was already used returned the generic 'Invalid or expired verification token' error, which looks like a broken account to the user (typical case: double click, or the mail client prefetching the link).
The verification token now carries an HMAC marker (vmk) bound to the account's current email_verified_at. verifyEmailToken returns a typed result (verified / already_verified / invalid):
Tokens issued before this change have no marker and keep working while the account is unverified and the JWT has not expired.
Route returns alreadyVerified; frontend shows a friendly message and logs the user in (ES/EN strings added).