Skip to content

Comments

fix auth#553

Closed
hiheyhello123 wants to merge 2 commits intostagingfrom
fix-alpha
Closed

fix auth#553
hiheyhello123 wants to merge 2 commits intostagingfrom
fix-alpha

Conversation

@hiheyhello123
Copy link
Contributor

@hiheyhello123 hiheyhello123 commented Apr 2, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Updated redirection so that unauthenticated users are now sent to the login page rather than the homepage.
  • New Features

    • Revamped the settings pages with a streamlined layout that adapts for mobile devices.
    • Added a loading indicator to enhance the visual experience while content is being fetched.

@vercel
Copy link

vercel bot commented Apr 2, 2025

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

Name Status Preview Comments Updated (UTC)
0 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 2, 2025 3:08am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 2, 2025

Walkthrough

This pull request updates the redirection logic for mail routes and restructures the settings layout. The mail page and create page functions now redirect unauthenticated users to the login page (/login) instead of the root path. Additionally, the settings layout has been refactored into an asynchronous function with a session check, and it no longer contains the previously embedded layout content and skeleton components. New UI components have been introduced for managing the settings layout content and a loading skeleton view.

Changes

File(s) Change Summary
apps/mail/app/(routes)/mail/[folder]/page.tsx
apps/mail/app/(routes)/mail/create/page.tsx
Updated redirection logic: unauthenticated users now redirect to /login instead of /.
apps/mail/app/(routes)/settings/layout.tsx Refactored SettingsLayout to an async function that retrieves session data and redirects to /login if missing; removed internal layout components (SettingsLayoutContent and SettingsLayoutSkeleton).
apps/mail/components/ui/settings-layout-content.tsx
apps/mail/components/ui/settings-layout-skeleton.tsx
Introduced new UI components: SettingsLayoutContent manages responsive layout elements, and SettingsLayoutSkeleton provides a loading placeholder for settings.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant M as MailPage/CreatePage
    participant S as Session Checker
    U->>M: Request Mail or Create Page
    M->>S: Verify session
    alt Session exists
       S-->>M: Session data
       M-->>U: Render page
    else No session
       S-->>M: No session
       M->>U: Redirect to /login
    end
Loading
sequenceDiagram
    participant U as User
    participant SL as SettingsLayout (async)
    participant A as Auth Library
    U->>SL: Request Settings Layout
    SL->>A: Check session asynchronously
    alt Session exists
       A-->>SL: Session data
       SL-->>U: Render settings layout with children
    else No session
       A-->>SL: No session
       SL->>U: Redirect to /login
    end
Loading

Possibly related PRs

Suggested reviewers

  • ahmetskilinc
  • nizzyabi

Poem

I'm a rabbit with a hop so light,
Changing routes in code by night.
Sessions checked, paths now are clear,
Login's the aim when nothing's near.
With layouts fresh and tweaks so right,
I celebrate each bug's goodnight!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@hiheyhello123 hiheyhello123 marked this pull request as draft April 2, 2025 03:08
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 (4)
apps/mail/components/ui/settings-layout-content.tsx (2)

33-37: Consider consolidating panel sizing properties

Both defaultSize and minSize are set to identical values (isMobile ? 100 : 35). If they're intended to always be the same, consider using a variable to avoid repetition.

+ const panelSize = isMobile ? 100 : 35;
  <ResizablePanel
    className="border-none !bg-transparent"
-   defaultSize={isMobile ? 100 : 35}
-   minSize={isMobile ? 100 : 35}
+   defaultSize={panelSize}
+   minSize={panelSize}
  >

42-42: Consider adding a comment for the complex height calculation

The height calculation h-[calc(100dvh-56px)] and md:h-[calc(100dvh-(8px+8px+14px+44px))] is quite complex and might be difficult to understand or maintain. Consider adding a comment explaining the calculation or using CSS variables to make it more maintainable.

apps/mail/app/(routes)/settings/layout.tsx (2)

8-10: Add error handling for potential getSession failures.

While fetching session data using auth.api.getSession, consider wrapping it in a try/catch block or handling potential errors gracefully to avoid unhandled promises.

-export default async function SettingsLayout({ children }: { children: React.ReactNode }) {
-  const headersList = await headers();
-  const session = await auth.api.getSession({ headers: headersList });
+export default async function SettingsLayout({ children }: { children: React.ReactNode }) {
+  try {
+    const headersList = await headers();
+    const session = await auth.api.getSession({ headers: headersList });
+    // ...
+  } catch (error) {
+    // Handle error, e.g. redirect or log
+  }

12-14: Consider preserving the original path on redirect.

Currently, unauthenticated users are redirected to /login without reference to their destination. For a better user experience, consider appending a next parameter so the user can be redirected back to the intended path after logging in.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b4171f8 and e9849c7.

📒 Files selected for processing (5)
  • apps/mail/app/(routes)/mail/[folder]/page.tsx (1 hunks)
  • apps/mail/app/(routes)/mail/create/page.tsx (1 hunks)
  • apps/mail/app/(routes)/settings/layout.tsx (1 hunks)
  • apps/mail/components/ui/settings-layout-content.tsx (1 hunks)
  • apps/mail/components/ui/settings-layout-skeleton.tsx (1 hunks)
🔇 Additional comments (5)
apps/mail/components/ui/settings-layout-content.tsx (1)

9-52: Good extraction of component logic with proper separation of concerns

Great job extracting the SettingsLayoutContent component from the settings layout file. This separation follows React best practices by isolating UI concerns from routing/authentication logic.

I like the proper cleanup of event listeners in the useEffect hook, preventing memory leaks.

apps/mail/app/(routes)/mail/create/page.tsx (1)

10-12: Improved authentication redirect path

Good change to redirect unauthenticated users to the /login page instead of the root page. This provides a better user experience by explicitly directing users to authenticate.

apps/mail/app/(routes)/mail/[folder]/page.tsx (1)

18-20: Consistent authentication redirect update

This change correctly updates the redirect path for unauthenticated users to /login, matching the same improvement made in the mail create page. This consistency ensures a uniform authentication experience across different routes.

apps/mail/components/ui/settings-layout-skeleton.tsx (1)

1-10: Good extraction of skeleton component

The SettingsLayoutSkeleton component has been properly extracted into its own file, following good separation of concerns. The implementation is clean and focused on providing a loading state UI.

The use of animate-pulse for the loading effect and svh units for viewport-aware height calculation are good practices.

apps/mail/app/(routes)/settings/layout.tsx (1)

2-6: Imports look correct.

All imported modules are relevant; no immediate issues or redundancies found.

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