Skip to content

Refactor exports. Fix account linking. Remove unused props.#658

Merged
edulelis merged 3 commits intoelie222:stagingfrom
edulelis:migrate-to-better-auth
Aug 6, 2025
Merged

Refactor exports. Fix account linking. Remove unused props.#658
edulelis merged 3 commits intoelie222:stagingfrom
edulelis:migrate-to-better-auth

Conversation

@edulelis
Copy link
Collaborator

@edulelis edulelis commented Aug 6, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Simplified session retrieval throughout the app for improved reliability and maintainability.
    • Updated Microsoft account linking to improve account matching logic.
  • Refactor

    • Streamlined authentication client usage and refactored related imports and exports.
    • Removed unused or redundant environment variables and configuration options.
    • Cleaned up and standardized the use of session hooks in components and providers.
  • Documentation

    • Updated README instructions for Google OAuth setup to include an additional redirect URI.

@vercel
Copy link

vercel bot commented Aug 6, 2025

@edulelis is attempting to deploy a commit to the Inbox Zero OSS Program Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 6, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This change refactors session retrieval across the web application by replacing explicit header passing to the authentication API with a simplified direct auth() call. It also updates authentication client imports, modifies environment and authentication configuration (including renaming and removing cookie-related options), and adjusts related documentation and provider callback URLs.

Changes

Cohort / File(s) Change Summary
Session Retrieval Refactor
apps/web/app/(app)/ErrorMessages.tsx, apps/web/app/(app)/[emailAccountId]/debug/rule-history/[ruleId]/page.tsx, apps/web/app/(app)/admin/page.tsx, apps/web/app/(app)/layout.tsx, apps/web/app/(landing)/welcome/page.tsx, apps/web/app/(landing)/login/page.tsx, apps/web/app/api/user/complete-registration/route.ts, apps/web/app/api/user/me/route.ts, apps/web/utils/account.ts, apps/web/utils/actions/safe-action.ts, apps/web/utils/email-account.ts, apps/web/utils/error.server.ts, apps/web/utils/middleware.ts
Replaces auth.api.getSession({ headers: await headers() }) with direct auth() calls, removing explicit header extraction and simplifying session retrieval throughout the codebase.
Authentication Client Import Refactor
apps/web/app/(app)/[emailAccountId]/settings/MultiAccountSection.tsx, apps/web/app/(landing)/login/LoginForm.tsx, apps/web/components/TopNav.tsx, apps/web/providers/PostHogProvider.tsx, apps/web/providers/SessionProvider.tsx, apps/web/utils/auth-client.ts, apps/web/utils/user.ts
Updates imports to use direct named exports (useSession, signIn, etc.) from the authentication client module, removing intermediate variables and simplifying usage.
Authentication Configuration Overhaul
apps/web/utils/auth.ts, apps/web/app/api/auth/[...all]/route.ts
Renames the main export from auth to betterAuthConfig, removes cookie and provider options, enables event handlers, updates error handling, and adds a new async auth function for session retrieval. Updates API handler to use betterAuthConfig.
OAuth Redirects and Documentation
README.md, apps/web/app/(app)/accounts/AddAccount.tsx
Updates OAuth redirect URIs in documentation and adjusts callback URLs for social sign-in flows, removing the newUserCallbackURL parameter.
Provider Callback Logic
apps/web/app/api/outlook/linking/callback/route.ts
Changes Microsoft account linking logic to validate only by email, not account ID, and updates database queries and logging accordingly.
Environment Variable Schema
apps/web/env.ts
Removes the COOKIE_DOMAIN environment variable from the server-side schema.
Email Assessment Logic
apps/web/utils/assess.ts
Changes message retrieval in getEmailClients to use getSentMessages(50) instead of a query string filter.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WebApp
    participant AuthModule
    participant Headers

    User->>WebApp: Makes request (e.g., page load)
    WebApp->>AuthModule: Calls auth()
    AuthModule->>Headers: Retrieves current request headers (if needed)
    AuthModule->>AuthModule: Processes session retrieval
    AuthModule-->>WebApp: Returns session object
    WebApp-->>User: Renders response based on session
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Poem

A bunny hopped through fields of code,
Refactoring sessions, lightening the load.
Headers now gone, just auth() in play,
Simpler imports brighten the day.
Cookies and configs, tidied anew—
With each little hop, the app grew!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 243a6a1 and 4dee238.

📒 Files selected for processing (27)
  • README.md (1 hunks)
  • apps/web/app/(app)/ErrorMessages.tsx (1 hunks)
  • apps/web/app/(app)/[emailAccountId]/debug/rule-history/[ruleId]/page.tsx (1 hunks)
  • apps/web/app/(app)/[emailAccountId]/settings/MultiAccountSection.tsx (2 hunks)
  • apps/web/app/(app)/accounts/AddAccount.tsx (3 hunks)
  • apps/web/app/(app)/admin/page.tsx (1 hunks)
  • apps/web/app/(app)/layout.tsx (1 hunks)
  • apps/web/app/(landing)/login/LoginForm.tsx (3 hunks)
  • apps/web/app/(landing)/login/page.tsx (3 hunks)
  • apps/web/app/(landing)/welcome/page.tsx (1 hunks)
  • apps/web/app/api/auth/[...all]/route.ts (1 hunks)
  • apps/web/app/api/outlook/linking/callback/route.ts (4 hunks)
  • apps/web/app/api/user/complete-registration/route.ts (1 hunks)
  • apps/web/app/api/user/me/route.ts (1 hunks)
  • apps/web/components/TopNav.tsx (2 hunks)
  • apps/web/env.ts (0 hunks)
  • apps/web/providers/PostHogProvider.tsx (2 hunks)
  • apps/web/providers/SessionProvider.tsx (1 hunks)
  • apps/web/utils/account.ts (1 hunks)
  • apps/web/utils/actions/safe-action.ts (3 hunks)
  • apps/web/utils/assess.ts (1 hunks)
  • apps/web/utils/auth-client.ts (1 hunks)
  • apps/web/utils/auth.ts (6 hunks)
  • apps/web/utils/email-account.ts (1 hunks)
  • apps/web/utils/error.server.ts (1 hunks)
  • apps/web/utils/middleware.ts (1 hunks)
  • apps/web/utils/user.ts (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
  • 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 explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @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.

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.

@edulelis edulelis merged commit 0f23b94 into elie222:staging Aug 6, 2025
7 of 10 checks passed
This was referenced Sep 3, 2025
This was referenced Dec 9, 2025
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

Comments