Feat/email verification otp#37
Merged
Merged
Conversation
Add the foundation for 6-digit OTP email verification: - GenerateOTPCode(): crypto-random zero-padded 6-digit code. - Verification.Attempts: track failed OTP entries (enforce a max before resend). - NewEmailVerificationCode(): constructor producing an email verification record whose Token holds the OTP code. Covered by account/otp_test.go. Subsequent commits add the store lookup, engine issue/verify, API, and notification wiring. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Wire the missing email-verification flow end-to-end on the engine/store side: - Engine: IssueEmailVerification (mint 6-digit OTP, store it, fire ActionEmailVerificationRequested carrying the code) and VerifyEmailCode (per-user lookup, expiry, max-attempts, constant-time compare → set EmailVerified). SignUp now issues a code for unverified users. Adds ErrTooManyAttempts. - Store: GetActiveEmailVerification(userID) + UpdateVerification on the interface and all four backends (memory/postgres/sqlite/mongo), plus an `attempts` column and a non-unique token index (6-digit codes are not globally unique) with a per-user active-code index. Covered by service_otp_test.go (issue, wrong→right, max-attempts) and account/otp_test.go. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- API: POST /v1/verify-email now accepts {code} (verifies the authenticated
session user's email via VerifyEmailCode) in addition to legacy {token};
ErrTooManyAttempts maps to HTTP 429.
- Engine: SendEmailVerification + SignUp + resend all delegate to one OTP issue
path (issueEmailVerificationForUser), so the hook carries `code` everywhere.
- Notification: OnAfterUserCreate is now a no-op — the engine owns issuance and
fires ActionEmailVerificationRequested (carrying the code), delivered by
handleHookEvent. Stops the previous duplicate, tokenless email.
- Update the resend hook test to assert the 6-digit code.
Full backend suite (account/api/memory/plugins/root) green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The @authsome/ui-components EmailVerificationForm submits the OTP as
{token: <6-digit code>}. Detect a 6-digit numeric value from an authenticated
session user and verify it via the secure per-user VerifyEmailCode path
(attempt-limited, constant-time) instead of the global token lookup; long
tokens and the unauthenticated fallback still use VerifyEmail.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
authsome_verifications.env_id is a non-null FK, but the OTP issue path never set it, so CreateVerification failed with fk_authsome_verifications_env and no code was ever minted. Populate EnvID from the app's default environment before insert. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
No description provided.