Email verification: code alongside the link, app chooses what to show#51
Open
sambhav-aggarwal wants to merge 1 commit into
Open
Email verification: code alongside the link, app chooses what to show#51sambhav-aggarwal wants to merge 1 commit into
sambhav-aggarwal wants to merge 1 commit into
Conversation
The verification email now carries both proofs — the signed link and a
numeric code — so the session that is WAITING can complete verification
in place: cross-device signups (register on desktop, read mail on
phone), limited-input devices, and environments where security
scanners consume single-use links (Outlook SafeLinks et al).
Which proofs to surface is the developer's choice, exercised in code
they already own — the ejected email-verify template (new $otp
variable in the RFC 002 §5.5 contract) and their UI — not a config
toggle. The old email_verification_method key does not return; the
package always provides both capabilities:
- AuthService::sendEmailVerification() issues the code with the link
(repurposing the previously unused polymorphic otp table)
- POST {prefix}/email/verify-otp (API, throttle 5/min) and a Verify
form on the Blade kit's verification page complete it
- Codes: hashed at rest, otp_expiry_time lifetime, invalidated after
5 wrong attempts (OTP::MAX_ATTEMPTS invariant) and by the link
succeeding — either proof kills the other via markEmailAsVerified()
- Reset / email-change mails carry no code (link-only purposes)
- API resend endpoint deduplicated through the service (also fixes it
ignoring the blade-vs-headless URL choice)
- otp table gains an attempts column (UPGRADING note for existing
installs); SPA guide gains the waiting-screen section (code entry
or poll/re-check)
9 new tests incl. attempt-cap exhaustion, expiry, resend-resets-
attempts, mutual invalidation, and no-code-on-reset. Suite 1014 green;
Pint and PHPStan clean.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
10 tasks
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.
What
Implements the dual-proof verification design discussed with the maintainer: the verification email now carries both a signed link and a numeric code, so the session that is waiting can complete verification in place — cross-device signups (register on desktop, read mail on phone), limited-input devices, and environments where corporate security scanners (Outlook SafeLinks, Mimecast) consume single-use links before the user clicks.
The choice mechanism — deliberately not a config toggle
The old
email_verification_methodkey does not return. The package always provides both capabilities; the developer chooses what to surface in code they already own (per RFC 002's template-ownership model):email-verifytemplate gains$otpin its variable contract (null for reset/email-change purposes) — show the link, the code, or bothThe default template and Blade-kit verification page show both, so the golden path covers every device type with zero decisions.
Mechanics
AuthService::sendEmailVerification()issues the code with the link — repurposing the previously unused polymorphicotptable (one active code per user; resend replaces it and resets attempts)POST {prefix}/email/verify-otp(authenticated, throttle 5/min) + a Verify form on the kit's verification pageotp_expiry_timelifetime; hard cap of 5 wrong attempts (OTP::MAX_ATTEMPTS— an invariant, not config); mutual invalidation: whichever proof succeeds kills the other viamarkEmailAsVerified()otptable gainsattempts(edit-in-place migration; UPGRADING note for existing installs)Testing
9 new tests: email carries both proofs, valid/wrong/expired codes, attempt-cap exhaustion kills even the correct code, resend resets attempts and invalidates the old code, link-verification kills the outstanding code, already-verified 400, and reset mails carry no code. Suite 1014 green; Pint and PHPStan clean.