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

Undo file changes in analytics platform #2532

Merged
merged 1 commit into from
Feb 26, 2025
Merged

Conversation

Codebmk
Copy link
Member

@Codebmk Codebmk commented Feb 26, 2025

This pull request includes several changes aimed at simplifying the authentication flow and removing unused code. The most important changes include removing Google authentication logic, simplifying the withAuth higher-order component, and updating the Home component export.

Improvements to authentication flow:

Code cleanup:

Component export update:

Summary by CodeRabbit

  • Refactor
    • Streamlined user authentication for a more direct experience, with users redirected promptly to login when not authenticated.
    • Updated the Home view delivery for improved consistency.
    • Removed the alternative sign-in option from the login page, now supporting only standard email and password authentication.

@Codebmk Codebmk requested a review from Baalmart February 26, 2025 08:00
@Codebmk Codebmk self-assigned this Feb 26, 2025
Copy link

coderabbitai bot commented Feb 26, 2025

📝 Walkthrough

Walkthrough

This PR streamlines the authentication process. The withAuth higher-order component in protectedRoute.js is simplified by removing several state hooks, retry logic, and session setup functions. Additionally, the Home page export is refactored to use a direct withAuth wrapper, eliminating dynamic SSR imports, while the login page no longer offers a Google login option.

Changes

File Change Summary
src/.../core/utils/protectedRoute.js Removed state hooks (isRedirecting, redirectToLogin, isMounted), functions (setupUserSession, retryWithDelay), and simplified the authentication check & redirection.
src/.../pages/Home/index.jsx Removed dynamic import; updated export from dynamic(() => Promise.resolve(withAuth(Home)), { ssr: false }) to a direct withAuth(Home), eliminating SSR wrapping.
src/.../pages/account/login/index.jsx Removed the handleGoogleLogin function and its associated UI, thereby eliminating the Google login option.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant A as withAuth HOC
    participant R as Router

    U->>A: Request access to a protected page
    A->>A: Check if user is authenticated
    alt Authenticated
        A-->>U: Render protected page
    else Not Authenticated
        A->>R: router.push('/account/login')
        R-->>U: Redirect to login page
    end
Loading

Possibly related PRs

Suggested reviewers

  • Baalmart
  • OchiengPaul442

Poem

In the code where logic flows,
Simplicity sparkles and clarity grows.
WithAuth refined, no extra fuss,
Login streamlined, no more excess.
Here's to cleaner code and easier days – hooray!
🚀🐰 Happy refactoring in our digital maze!

Tip

CodeRabbit's docstrings feature is now available as part of our Pro Plan! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f7522e7 and b50213e.

📒 Files selected for processing (3)
  • src/platform/src/core/utils/protectedRoute.js (1 hunks)
  • src/platform/src/pages/Home/index.jsx (2 hunks)
  • src/platform/src/pages/account/login/index.jsx (0 hunks)
💤 Files with no reviewable changes (1)
  • src/platform/src/pages/account/login/index.jsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build-push-deploy-analytics-platform-preview
  • GitHub Check: test-analytics-platform-changes
🔇 Additional comments (4)
src/platform/src/pages/Home/index.jsx (1)

305-305: Simplified export with direct HOC application

The change from using dynamic import with { ssr: false } to directly exporting with withAuth(Home) simplifies the code and makes the intention clearer. This aligns well with the PR objective of simplifying the authentication flow.

However, be aware that this change might affect how the component is rendered on the server side and could impact code splitting benefits that were previously provided by the dynamic import.

Consider verifying that removing the dynamic import doesn't negatively impact page load performance, especially for users with slower connections.

src/platform/src/core/utils/protectedRoute.js (3)

12-24: Streamlined authentication flow with cleaner implementation

The authentication logic has been significantly simplified, removing unnecessary state management and complex redirection logic. The code is now more straightforward, focusing on its primary responsibility: checking authentication status and rendering the wrapped component only when the user is authenticated.

The use of LogoutUser utility centralizes logout logic, which improves maintainability and keeps the HOC focused on its core purpose.


4-4: Good practice: Centralizing logout functionality

Importing and using the LogoutUser utility centralizes the logout functionality, which is a good practice for code organization and maintenance. This ensures consistent behavior when logging users out across the application.


26-26: Helpful code comment

Adding this comment improves code readability by clearly explaining the conditional rendering logic.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
  • @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 or @coderabbitai title 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.

Copy link
Contributor

New next-platform changes available for preview here

@Baalmart Baalmart merged commit 6fe6134 into staging Feb 26, 2025
28 of 29 checks passed
@Baalmart Baalmart deleted the feat-google-login branch February 26, 2025 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants