Skip to content
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

🐛 Fix issues with email change flow #1495

Merged
merged 3 commits into from
Jan 14, 2025
Merged

🐛 Fix issues with email change flow #1495

merged 3 commits into from
Jan 14, 2025

Conversation

lukevella
Copy link
Owner

@lukevella lukevella commented Jan 14, 2025

Summary by CodeRabbit

  • User Experience Improvements

    • Updated email-related error message to provide clearer guidance when an email is already associated with another account.
    • Modified email change request email text to suggest ignoring the message if not requested by the user.
  • Form Validation Enhancements

    • Introduced new validation schemas for email change and profile settings forms, improving user feedback and submission processes.

Copy link

vercel bot commented Jan 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 14, 2025 5:57pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
landing ⬜️ Skipped (Inspect) Jan 14, 2025 5:57pm

Copy link
Contributor

coderabbitai bot commented Jan 14, 2025

Warning

Rate limit exceeded

@lukevella has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 26 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 2e68176 and a9df0b1.

📒 Files selected for processing (2)
  • apps/web/src/app/[locale]/(admin)/settings/profile/profile-email-address.tsx (3 hunks)
  • apps/web/src/app/[locale]/(admin)/settings/profile/profile-settings.tsx (2 hunks)

Walkthrough

This pull request focuses on enhancing user communication regarding email management. The changes involve updating localization strings in the web application and email templates, specifically addressing scenarios related to email usage and change requests. The modifications aim to provide clearer instructions to users when they encounter email-related actions, such as during registration or when requesting an email change.

Changes

File Change Summary
apps/web/public/locales/en/app.json Updated emailAlreadyInUse message to clarify that the email is associated with another account.
apps/web/src/app/[locale]/(admin)/settings/profile/profile-email-address.tsx Introduced a new validation schema for the email change form using zod, updated form state handling, and simplified default values.
packages/emails/locales/en/emails.json Modified changeEmailRequest_text3 to suggest ignoring the email instead of contacting support.
apps/web/src/app/[locale]/(admin)/settings/profile/profile-settings.tsx Added a validation schema for the profile settings form, updated types, and integrated FormMessage for validation feedback.

Sequence Diagram

sequenceDiagram
    participant User
    participant WebApp
    participant EmailService
    
    User->>WebApp: Attempt email change
    WebApp->>EmailService: Send email change request
    EmailService-->>User: Send verification email
    User->>WebApp: Confirm email change
    WebApp->>WebApp: Validate and process change
    WebApp-->>User: Confirm successful email update
Loading

Possibly related PRs

  • ✨ Enable changing user email address #1493: The changes in this PR include modifications to the emailAlreadyInUse message in apps/web/public/locales/en/app.json, which directly relates to the main PR's update of the same key in the same file, enhancing user feedback regarding email usage.
  • 🌐 New Crowdin updates #1494: This PR also updates the emailAlreadyInUse key in multiple localization files, including apps/web/public/locales/cs/app.json, apps/web/public/locales/nl/app.json, and others, which aligns with the main PR's focus on improving the clarity of the email usage message.

Poem

🐰 A Rabbit's Ode to Email Clarity

With words precise, we now explain,
No more confusion, no more pain,
Emails linked, instructions clear,
A message sent with rabbit cheer! 🌟
Changing emails, smooth and bright! 📧


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@vercel vercel bot temporarily deployed to Preview – landing January 14, 2025 17:49 Inactive
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
apps/web/src/app/[locale]/(admin)/settings/profile/profile-settings.tsx (1)

63-63: Consider adding specific validation messages.

While FormMessage will show validation errors, consider customizing the messages for better user experience.

-                  <FormMessage />
+                  <FormMessage
+                    error={{
+                      required: t("nameRequired", "Name is required"),
+                      min: t("nameMin", "Name must be at least 1 character"),
+                      max: t("nameMax", "Name cannot exceed 100 characters")
+                    }}
+                  />
apps/web/src/app/[locale]/(admin)/settings/profile/profile-email-address.tsx (1)

26-28: Consider strengthening email validation.

While zod's built-in email validator is good, consider adding additional constraints for better security and UX.

 const emailChangeFormData = z.object({
-  email: z.string().email(),
+  email: z.string()
+    .min(5, "Email must be at least 5 characters")
+    .max(254, "Email cannot exceed 254 characters")
+    .email("Please enter a valid email address")
+    .transform((email) => email.toLowerCase()),
 });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4ea2aab and 2e68176.

📒 Files selected for processing (2)
  • apps/web/src/app/[locale]/(admin)/settings/profile/profile-email-address.tsx (2 hunks)
  • apps/web/src/app/[locale]/(admin)/settings/profile/profile-settings.tsx (3 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 (4)
apps/web/src/app/[locale]/(admin)/settings/profile/profile-settings.tsx (2)

20-22: LGTM! Well-structured validation schema.

The name validation constraints (1-100 characters) are reasonable and the schema is properly defined.


30-34: LGTM! Clean form configuration.

Good separation of concerns by moving email management to a separate component and proper integration of zod validation.

apps/web/src/app/[locale]/(admin)/settings/profile/profile-email-address.tsx (2)

35-40: LGTM! Clean form setup with validation.

Good integration of zod schema with react-hook-form and proper default value handling.


105-105: Verify form reset timing.

The form reset is correctly placed after successful mutation, but ensure it doesn't interfere with the success message display.

✅ Verification successful

Form reset timing is correctly implemented

The reset timing won't interfere with the success message display because:

  • The toast system has a 2-second display duration
  • This implementation follows the same pattern used successfully throughout the codebase
  • Toast notifications are managed independently of form state
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar patterns in other form handlers
rg -A 5 "reset\(.*\)" --type ts --type tsx

Length of output: 72


Script:

#!/bin/bash
# Search for form reset patterns with correct file types
rg -t typescript -t javascriptreact -t typescriptreact "reset\(" -A 5

# Search for success message patterns near reset calls
rg -t typescript -t javascriptreact -t typescriptreact "reset\(.*\).*success" -B 5 -A 5

# Use ast-grep to find mutation success handlers
ast-grep --pattern 'onSuccess: ($$$) => {
  $$$
}'

Length of output: 284


Script:

#!/bin/bash
# Find files containing reset calls
fd -e ts -e tsx -x rg -l "reset\("

# Search for reset calls in context
fd -e ts -e tsx -x rg -B 10 -A 5 "onSuccess.*\{" {} \;

# Look for toast/notification patterns near reset
fd -e ts -e tsx -x rg -B 5 -A 5 "toast|notification|success.*message" {} \;

Length of output: 27946

@vercel vercel bot temporarily deployed to Preview – landing January 14, 2025 17:53 Inactive
@lukevella lukevella merged commit 4e2661b into main Jan 14, 2025
9 checks passed
@lukevella lukevella deleted the fix-email-change branch January 14, 2025 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant