fix: require email verification for password signup#30
Open
BunsDev wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the authentication and invitation flows to mitigate account pre-hijacking by requiring email verification for password-based signups and gating invitation promotion/acceptance on emailVerified.
Changes:
- Enabled email verification + disabled immediate session creation for email/password signups in the Better Auth server config, including a verification-email callback.
- Added a new email verification template and a
sendEmailVerificationEmailhelper to the shared email package. - Updated portal signup UI to stop after password signup and show a “Check your email” state, and blocked invitation send/accept flows for unverified users.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/email/src/templates/email-verification.tsx | Adds the React Email template used for verification emails. |
| packages/email/src/index.ts | Adds sendEmailVerificationEmail helper and exports the new template. |
| apps/web/src/lib/server/functions/invitations.ts | Requires session.user.emailVerified before accepting invitations. |
| apps/web/src/lib/server/functions/admin.ts | Blocks sending invitations to existing users whose email is not verified. |
| apps/web/src/lib/server/auth/index.ts | Disables auto-sign-in on password signup, requires verification, and wires verification email sending. |
| apps/web/src/components/auth/portal-auth-form.tsx | Updates full-page portal auth UX to show a verify-email state after password signup and pass callbackURL. |
| apps/web/src/components/auth/portal-auth-form-inline.tsx | Updates inline portal auth UX similarly (verify-email state + callbackURL). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
85af585 to
a560a1c
Compare
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
a560a1c to
dbd9fbd
Compare
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.
Motivation
Description
emailAndPasswordconfig by settingautoSignIn: falseandrequireEmailVerification: trueinapps/web/src/lib/server/auth/index.tsand wired a verification callback that sends a verification email.EmailVerificationEmailtemplate andsendEmailVerificationEmailhelper inpackages/emailand exported it frompackages/email/src/index.ts.apps/web/src/components/auth/portal-auth-form.tsxandportal-auth-form-inline.tsx) to pass acallbackURLwhen callingauthClient.signUp.email, stop after signup, and show a “Check your email” verification state instead of redirecting into an active session.emailVerified === falseinapps/web/src/lib/server/functions/admin.tsand requiringsession.user.emailVerifiedwhen accepting an invitation inapps/web/src/lib/server/functions/invitations.ts.Testing
git diff --checkwith no issues.bun run typecheck, which could not complete in this environment due to missing type packages (registry access produced 403s), so full typecheck/tests were not executable here.Codex Task