Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe pull request introduces an early access check in the authentication middleware by modifying the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant AuthMiddleware
participant DB
Client->>AuthMiddleware: Initiate authentication
AuthMiddleware->>DB: Query earlyAccess table by email
DB-->>AuthMiddleware: Return early access record
alt Early access granted
AuthMiddleware->>Client: Proceed with session
else Early access denied
AuthMiddleware->>Client: Throw error, deny session
end
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
🪧 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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
apps/mail/lib/auth.ts (2)
70-80: Early access verification logic implementation looks good.The implementation properly queries the early access table and verifies if the user has the required permissions before proceeding with authentication. The code follows the existing pattern of using drizzle ORM to query the database.
I have one minor suggestion regarding error handling:
Consider using a more specific error type or adding an error code to make it easier to handle this specific error case in the UI layer:
- throw new Error("Early access required. Please join the waitlist."); + throw new Error("EARLY_ACCESS_REQUIRED: Please join the waitlist.");Or even better, create a custom error class:
class EarlyAccessRequiredError extends Error { constructor(message = "Early access required. Please join the waitlist.") { super(message); this.name = "EarlyAccessRequiredError"; } } // Then use it like: throw new EarlyAccessRequiredError();
70-80: Consider case sensitivity in email comparison.The current implementation directly compares emails without handling potential case sensitivity issues. While most email providers treat emails as case-insensitive, the database comparison might be case-sensitive depending on the collation settings.
Consider normalizing the email address before comparison:
// First, check if user has early access const [earlyAccessUser] = await db .select() .from(earlyAccess) - .where(eq(earlyAccess.email, user.email)) + .where(eq(earlyAccess.email, user.email.toLowerCase())) .limit(1);Additionally, ensure that emails are consistently stored in lowercase in the
early_accesstable.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/mail/lib/auth.ts(2 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
apps/mail/lib/auth.ts (2)
packages/db/src/index.ts (1)
db(17-17)packages/db/src/schema.ts (2)
earlyAccess(57-63)user(6-15)
🔇 Additional comments (3)
apps/mail/lib/auth.ts (3)
2-2: Updated import statement to include early access functionality.The import statement now includes
earlyAccessfrom the database schema, which is necessary for the early access check implementation.
70-76: Verify error handling for database query failures.The query to check for early access could fail due to database connectivity issues or other reasons. The current implementation doesn't handle these potential errors explicitly.
Consider adding try-catch blocks around the database query to gracefully handle potential database errors:
+ try { // First, check if user has early access const [earlyAccessUser] = await db .select() .from(earlyAccess) .where(eq(earlyAccess.email, user.email)) .limit(1); + } catch (error) { + console.error("Failed to check early access status:", error); + throw new Error("Unable to verify access status. Please try again later."); + }
77-80: Verify that the error message is properly displayed to users.The error message "Early access required. Please join the waitlist." is informative, but we should ensure it's properly displayed to users rather than being shown as a generic error.
Please verify that the error thrown here is properly caught and displayed in the UI, with appropriate guidance for users to join the waitlist. You might want to verify how error handling is implemented in the authentication flow.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/mail/lib/auth.ts (1)
82-84: Suggest adding test coverage for the early access logic.Throwing an error prevents further session handling when
hasEarlyAccessis falsy. This appears correct but should be tested to ensure reliable behavior.Would you like me to generate a test for verifying that non-early-access users cannot proceed?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/mail/lib/auth.ts(2 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
apps/mail/lib/auth.ts (2)
packages/db/src/index.ts (1)
db(17-17)packages/db/src/schema.ts (2)
earlyAccess(57-63)user(6-15)
🔇 Additional comments (4)
apps/mail/lib/auth.ts (4)
2-2: No issues with the new import.Importing
earlyAccessseems correct and aligns with the updated logic.
70-70: Thanks for the descriptive comment.This clarifies the intention behind combining the user lookup with the early access check. No changes needed.
74-77: Ensure intended behavior for missing early access rows.Using a left join to fetch
hasEarlyAccessimplies that users without anearly_accessrecord will be treated as lacking early access. Confirm if this strict approach aligns with product requirements. Otherwise, consider an inner join or separate logic to handle missing entries distinctly.
81-81: No additional feedback on the comment.
* adjustable height * h1 h2 h3 working in reply composer * select dropdown for categories * feat(navbar): update item label based on auth status * feature/persist user settings (#513) * feat: persist setting (codycodes95) * feat: update settings to jsonb * feat: run migration * feat: save changes to db * fix: naming * feat: validate settings schema * feat: add i18n * fix: set i18n variables * fix: coderabbit comment * feat: improve function readability * feat: use hook * fix:update settings --------- Co-authored-by: Cody Partington <codythatsme@gmail.com> * remove unique status from email in schema * early access check added to schema * updated readme * add contributors * remove text-decoration * text-decoration * remove auto focus on search * ahuh * gg * i18n * check email for early access (#519) * check email for early access * one check * saving... * disable buttons * disable * fix * saving... --------- Co-authored-by: Nizzy <nizabizaher@gmail.com> Co-authored-by: pietrodev07 <pietro.dev.07@gmail.com> Co-authored-by: Sergio JVA <60497216+sergio-jva@users.noreply.github.com> Co-authored-by: Cody Partington <codythatsme@gmail.com> Co-authored-by: Ahmet Kilinc <akx9@icloud.com> Co-authored-by: user12224 <122770437+user12224@users.noreply.github.com> Co-authored-by: nizzy <140507264+nizzyabi@users.noreply.github.com>
* adjustable height * h1 h2 h3 working in reply composer * select dropdown for categories * feat(navbar): update item label based on auth status * feature/persist user settings (#513) * feat: persist setting (codycodes95) * feat: update settings to jsonb * feat: run migration * feat: save changes to db * fix: naming * feat: validate settings schema * feat: add i18n * fix: set i18n variables * fix: coderabbit comment * feat: improve function readability * feat: use hook * fix:update settings --------- Co-authored-by: Cody Partington <codythatsme@gmail.com> * remove unique status from email in schema * early access check added to schema * updated readme * add contributors * remove text-decoration * text-decoration * remove auto focus on search * ahuh * gg * i18n * check email for early access (#519) * check email for early access * one check * saving... * disable buttons * disable * fix * saving... * saving... * minor * New translations en.json (French) * New translations en.json (Spanish) * New translations en.json (Arabic) * New translations en.json (Catalan) * New translations en.json (Czech) * New translations en.json (German) * New translations en.json (Japanese) * New translations en.json (Korean) * New translations en.json (Polish) * New translations en.json (Portuguese) * New translations en.json (Russian) * New translations en.json (Turkish) * New translations en.json (Latvian) * New translations en.json (Hindi) * New translations en.json (French) * New translations en.json (Spanish) * New translations en.json (Arabic) * New translations en.json (Catalan) * New translations en.json (German) * New translations en.json (Japanese) * New translations en.json (Korean) * New translations en.json (Polish) * New translations en.json (Portuguese) * New translations en.json (Hindi) * reply and searchbar display * reply ai (#526) * reply ai * ai functionality * line height * adam fixes --------- Co-authored-by: user12224 <122770437+user12224@users.noreply.github.com> Co-authored-by: Nizzy <nizabizaher@gmail.com> * Autocompletions for reply and create * email avatars (#528) * added email avatars * fix small issue * small ui fix * color fix * reply ui * New translations en.json (Japanese) * New translations en.json (Korean) * no drop down * ui fix * wip performance * saving... * saving... * saving... * saving... * - updated phrases - added delay of 2 matching characters * Improved ai with custom prompt (#534) * ai * improved ai * improved-ai-with-custom-prompt * empty commit * removed new lines * empty commit * search * forwarding * search filter removed. all in ai now * saving... * fix double submit on command enter create email * saving... * saving... * turn search ai into a server action * fuix * show most recent email in thread * saving... * saving... * forward and reply in one compose button * saving... * New translations en.json (French) * New translations en.json (Spanish) * New translations en.json (Arabic) * New translations en.json (Catalan) * New translations en.json (Czech) * New translations en.json (German) * New translations en.json (Japanese) * New translations en.json (Korean) * New translations en.json (Polish) * New translations en.json (Portuguese) * New translations en.json (Russian) * New translations en.json (Turkish) * New translations en.json (Latvian) * New translations en.json (Hindi) * fix to height reply composer * posthog * remove github login for now * refresh * New translations en.json (French) * New translations en.json (Spanish) * New translations en.json (Arabic) * New translations en.json (Catalan) * New translations en.json (Czech) * New translations en.json (German) * New translations en.json (Japanese) * New translations en.json (Korean) * New translations en.json (Polish) * New translations en.json (Portuguese) * New translations en.json (Russian) * New translations en.json (Turkish) * New translations en.json (Latvian) * New translations en.json (Hindi) * revert * a * fix load more * fix load more * remove use memo from thread to not load when opening an email * fix switching accounts --------- Co-authored-by: Nizzy <nizabizaher@gmail.com> Co-authored-by: pietrodev07 <pietro.dev.07@gmail.com> Co-authored-by: Sergio JVA <60497216+sergio-jva@users.noreply.github.com> Co-authored-by: Cody Partington <codythatsme@gmail.com> Co-authored-by: Ahmet Kilinc <akx9@icloud.com> Co-authored-by: user12224 <122770437+user12224@users.noreply.github.com> Co-authored-by: nizzy <140507264+nizzyabi@users.noreply.github.com> Co-authored-by: [bot] <zero@ibra.rip> Co-authored-by: needle <122770437+needleXO@users.noreply.github.com>
* adjustable height * h1 h2 h3 working in reply composer * select dropdown for categories * feat(navbar): update item label based on auth status * feature/persist user settings (#513) * feat: persist setting (codycodes95) * feat: update settings to jsonb * feat: run migration * feat: save changes to db * fix: naming * feat: validate settings schema * feat: add i18n * fix: set i18n variables * fix: coderabbit comment * feat: improve function readability * feat: use hook * fix:update settings --------- Co-authored-by: Cody Partington <codythatsme@gmail.com> * remove unique status from email in schema * early access check added to schema * updated readme * add contributors * remove text-decoration * text-decoration * remove auto focus on search * ahuh * gg * i18n * check email for early access (#519) * check email for early access * one check * saving... * disable buttons * disable * fix * saving... * saving... * minor * New translations en.json (French) * New translations en.json (Spanish) * New translations en.json (Arabic) * New translations en.json (Catalan) * New translations en.json (Czech) * New translations en.json (German) * New translations en.json (Japanese) * New translations en.json (Korean) * New translations en.json (Polish) * New translations en.json (Portuguese) * New translations en.json (Russian) * New translations en.json (Turkish) * New translations en.json (Latvian) * New translations en.json (Hindi) * New translations en.json (French) * New translations en.json (Spanish) * New translations en.json (Arabic) * New translations en.json (Catalan) * New translations en.json (German) * New translations en.json (Japanese) * New translations en.json (Korean) * New translations en.json (Polish) * New translations en.json (Portuguese) * New translations en.json (Hindi) * reply and searchbar display * reply ai (#526) * reply ai * ai functionality * line height * adam fixes --------- Co-authored-by: user12224 <122770437+user12224@users.noreply.github.com> Co-authored-by: Nizzy <nizabizaher@gmail.com> * Autocompletions for reply and create * email avatars (#528) * added email avatars * fix small issue * small ui fix * color fix * reply ui * New translations en.json (Japanese) * New translations en.json (Korean) * no drop down * ui fix * wip performance * saving... * saving... * saving... * saving... * - updated phrases - added delay of 2 matching characters * Improved ai with custom prompt (#534) * ai * improved ai * improved-ai-with-custom-prompt * empty commit * removed new lines * empty commit * search * forwarding * search filter removed. all in ai now * saving... * fix double submit on command enter create email * saving... * saving... * turn search ai into a server action * fuix * show most recent email in thread * saving... * saving... * forward and reply in one compose button * saving... * New translations en.json (French) * New translations en.json (Spanish) * New translations en.json (Arabic) * New translations en.json (Catalan) * New translations en.json (Czech) * New translations en.json (German) * New translations en.json (Japanese) * New translations en.json (Korean) * New translations en.json (Polish) * New translations en.json (Portuguese) * New translations en.json (Russian) * New translations en.json (Turkish) * New translations en.json (Latvian) * New translations en.json (Hindi) * fix to height reply composer * posthog * remove github login for now * refresh * New translations en.json (French) * New translations en.json (Spanish) * New translations en.json (Arabic) * New translations en.json (Catalan) * New translations en.json (Czech) * New translations en.json (German) * New translations en.json (Japanese) * New translations en.json (Korean) * New translations en.json (Polish) * New translations en.json (Portuguese) * New translations en.json (Russian) * New translations en.json (Turkish) * New translations en.json (Latvian) * New translations en.json (Hindi) * revert * a * fix load more * fix load more * remove use memo from thread to not load when opening an email * fix switching accounts * navbar changed to login --------- Co-authored-by: Nizzy <nizabizaher@gmail.com> Co-authored-by: pietrodev07 <pietro.dev.07@gmail.com> Co-authored-by: Sergio JVA <60497216+sergio-jva@users.noreply.github.com> Co-authored-by: Cody Partington <codythatsme@gmail.com> Co-authored-by: Adam <x_1337@outlook.com> Co-authored-by: Ahmet Kilinc <akx9@icloud.com> Co-authored-by: user12224 <122770437+user12224@users.noreply.github.com> Co-authored-by: nizzy <140507264+nizzyabi@users.noreply.github.com> Co-authored-by: [bot] <zero@ibra.rip>
READ CAREFULLY THEN REMOVE
Remove bullet points that are not relevant.
PLEASE REFRAIN FROM USING AI TO WRITE YOUR CODE AND PR DESCRIPTION. IF YOU DO USE AI TO WRITE YOUR CODE PLEASE PROVIDE A DESCRIPTION AND REVIEW IT CAREFULLY. MAKE SURE YOU UNDERSTAND THE CODE YOU ARE SUBMITTING USING AI.
Description
Please provide a clear description of your changes.
Type of Change
Please delete options that are not relevant.
Areas Affected
Please check all that apply:
Testing Done
Describe the tests you've done:
Security Considerations
For changes involving data or authentication:
Checklist
Additional Notes
Add any other context about the pull request here.
Screenshots/Recordings
Add screenshots or recordings here if applicable.
By submitting this pull request, I confirm that my contribution is made under the terms of the project's license.
Summary by CodeRabbit