-
-
Notifications
You must be signed in to change notification settings - Fork 396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🔒️ Block temporary inboxes #1602
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
WalkthroughThis pull request adds logic to prevent the use of temporary or disposable email addresses during registration. It updates the localization file with a new error message and modifies both client-side and server-side components to check for these emails. A new helper file is introduced to list known temporary email domains and to provide a function that validates provided emails. If a temporary email is detected, the system returns an error with a localized message. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant RegistrationForm
participant AuthRouter
participant TempEmailHelper
User->>RegistrationForm: Submit registration (email)
RegistrationForm->>AuthRouter: Request registration with email
AuthRouter->>TempEmailHelper: Call isTemporaryEmail(email)
TempEmailHelper-->>AuthRouter: Returns true if temporary email detected
AuthRouter-->>RegistrationForm: Respond with error "temporaryEmailNotAllowed"
RegistrationForm->>User: Display localized error message
Possibly related PRs
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
apps/web/src/auth/helpers/temp-email-domains.ts (1)
2-55
: Consider using a more comprehensive and maintainable approach for temporary email domains.While the current list covers many common temporary email providers, this approach has limitations:
- The list will need constant maintenance as new disposable email services appear
- Hard-coding all domains in the source code could become unwieldy
Consider implementing one of these alternatives:
- Use a regularly updated npm package like
disposable-email-domains
- Implement a database-backed list that can be updated without code changes
- Consider using an external API service that specializes in email validation
You could replace the hard-coded list with an npm package:
-// List of common temporary/disposable email domains -export const temporaryEmailDomains = [ - "10minutemail.com", - "temp-mail.org", - // ... many more domains -]; +import disposableDomains from 'disposable-email-domains'; + +// Use a comprehensive list of temporary/disposable email domains from npm package +export const temporaryEmailDomains = disposableDomains;apps/web/src/trpc/routers/auth.ts (1)
58-60
: Add logging for temporary email rejections.Consider adding analytics tracking or logging when a user is rejected due to a temporary email. This could provide valuable data on how frequently users attempt to register with disposable emails.
if (isTemporaryEmail(input.email)) { + // Log temporary email rejection for analytics + console.info(`Registration blocked for temporary email: ${input.email.split('@')[1]}`); + + // Optional: track with analytics if you use a service like Posthog + posthog?.capture({ + event: "temporary_email_blocked", + properties: { + domain: input.email.split('@')[1], + }, + }); + return { ok: false, reason: "temporaryEmailNotAllowed" }; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/web/public/locales/en/app.json
(1 hunks)apps/web/src/app/[locale]/(auth)/register/components/register-name-form.tsx
(1 hunks)apps/web/src/auth/helpers/temp-email-domains.ts
(1 hunks)apps/web/src/trpc/routers/auth.ts
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Unit tests
- GitHub Check: Type check
- GitHub Check: Linting
- GitHub Check: Integration tests
🔇 Additional comments (5)
apps/web/public/locales/en/app.json (1)
33-33
: Clear and concise error message for temporary emails.The addition of this localization string provides a clear and descriptive error message that will inform users about the temporary email restriction.
apps/web/src/app/[locale]/(auth)/register/components/register-name-form.tsx (1)
54-61
: Well-implemented error handling for temporary emails.The implementation follows the same pattern as other error cases, correctly showing the translated error message when a temporary email is detected. Good use of the defaultValue parameter to ensure fallback text is available if the translation is missing.
apps/web/src/trpc/routers/auth.ts (3)
9-9
: Appropriately imported the new helper function.Good job importing the
isTemporaryEmail
function from the newly created file.
46-52
: Updated return type to include the new error reason.The return type has been properly updated to include the new
temporaryEmailNotAllowed
reason, maintaining type safety.
58-60
: Validation properly implemented for temporary emails.The validation check is correctly placed before database queries, which is efficient. The implementation is consistent with the existing validation pattern for blocked emails.
Summary by CodeRabbit