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: #409 웹 환경에서 카카오 브라우저 로그인 시, 소셜 로그인 정책 우회 #419

Merged
merged 2 commits into from
Nov 4, 2024

Conversation

klmhyeonwoo
Copy link
Member

@klmhyeonwoo klmhyeonwoo commented Nov 3, 2024

PR 제목은 핵심 변경 사항을 요약해주세요


🏄🏼‍♂️‍ Summary (요약)

🫨 Describe your Change (변경사항)

🧐 Issue number and link (참고)

📚 Reference (참조)

Summary by CodeRabbit

  • New Features

    • Introduced a new component to manage external link handling for Kakao and Instagram users.
  • Bug Fixes

    • Removed outdated commented code to streamline the application.
  • Refactor

    • Updated component structure to enhance the interaction of PreventExternalBrowser with nested routes.
  • Chores

    • Updated file extensions to reflect the transition to TypeScript with JSX support.

Copy link

vercel bot commented Nov 3, 2024

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

Name Status Preview Comments Updated (UTC)
layer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 3, 2024 0:06am

Copy link

coderabbitai bot commented Nov 3, 2024

Walkthrough

The changes in this pull request involve modifications across multiple files, primarily focusing on the PreventExternalBrowser functionality. The old preventExternalBrowser.ts file has been removed, and a new preventExternalBrowser.tsx file has been introduced, which implements a React component to manage external link handling for Kakao and Instagram in-app browsers. Additionally, the GlobalLayout component has been updated to utilize the new PreventExternalBrowser component, altering its structure without changing underlying logic.

Changes

File Path Change Summary
apps/web/src/app.tsx Removed commented-out code and adjusted JSX structure; DevTools and ReactQueryDevtools commented out.
apps/web/src/helper/preventExternalBrowser.ts Deleted file containing the PreventExternalBrowser function for handling browser detection.
apps/web/src/helper/preventExternalBrowser.tsx Introduced new React component PreventExternalBrowser for managing external link navigation.
apps/web/src/layout/GlobalLayout.tsx Restructured usage of PreventExternalBrowser, wrapping Outlet and updated import path to .tsx.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant PreventExternalBrowser
    participant Kakao
    participant Instagram

    User->>App: Access application
    App->>PreventExternalBrowser: Check user agent
    alt Kakao detected
        PreventExternalBrowser->>Kakao: Redirect to KakaoTalk URL
    else Instagram detected
        PreventExternalBrowser->>User: Prompt to use system browser
    else Other
        PreventExternalBrowser->>App: Render children
    end
Loading

🐰 "In code's embrace, we hop and play,
Removing the clutter, brightening the way.
With Kakao's path and Instagram's cheer,
External links handled, no need to fear!
So let’s dance through the code, with joy we’ll sing,
For every small change, a new spring will bring!" 🐇


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 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.

@klmhyeonwoo
Copy link
Member Author

@coderabbitai review

@depromeet depromeet deleted a comment from coderabbitai bot Nov 3, 2024
@depromeet depromeet deleted a comment from coderabbitai bot Nov 3, 2024
Copy link

@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: 2

🧹 Outside diff range and nitpick comments (4)
apps/web/src/helper/preventExternalBrowser.tsx (3)

1-3: Add component documentation and explicit return type.

Consider adding JSDoc documentation and an explicit return type for better maintainability and type safety.

+/**
+ * Prevents external browser usage by detecting Kakao/Instagram in-app browsers
+ * and redirecting users to appropriate system browsers.
+ */
-export function PreventExternalBrowser({ children }: PropsWithChildren) {
+export function PreventExternalBrowser({ children }: PropsWithChildren): JSX.Element {

12-17: Implementation needed for Instagram in-app browser handling.

The Instagram handling is currently incomplete. Would you like assistance in implementing this feature?

I can help create a GitHub issue to track this TODO and provide a suggested implementation based on Instagram's WebView behavior.


18-19: Add debugging context to default rendering.

Consider adding data attributes to help with debugging and analytics.

-  return <Fragment> {children} </Fragment>;
+  return (
+    <Fragment>
+      <div data-browser-type={agent} data-is-external-browser="false">
+        {children}
+      </div>
+    </Fragment>
+  );
apps/web/src/layout/GlobalLayout.tsx (1)

8-8: Remove explicit .tsx extension from import statement.

The explicit .tsx extension in the import statement is unnecessary and could cause issues with different bundlers or build configurations. TypeScript/webpack automatically resolves these extensions.

-import { PreventExternalBrowser } from "@/helper/preventExternalBrowser.tsx";
+import { PreventExternalBrowser } from "@/helper/preventExternalBrowser";
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 07417c0 and 0487e44.

📒 Files selected for processing (4)
  • apps/web/src/app.tsx (0 hunks)
  • apps/web/src/helper/preventExternalBrowser.ts (0 hunks)
  • apps/web/src/helper/preventExternalBrowser.tsx (1 hunks)
  • apps/web/src/layout/GlobalLayout.tsx (2 hunks)
💤 Files with no reviewable changes (2)
  • apps/web/src/app.tsx
  • apps/web/src/helper/preventExternalBrowser.ts
🔇 Additional comments (2)
apps/web/src/helper/preventExternalBrowser.tsx (1)

1-19: Verify component integration across the codebase.

Let's ensure all imports are updated and the component is properly integrated.

✅ Verification successful

Component integration is properly implemented

The verification shows:

  • The component is correctly imported with .tsx extension in GlobalLayout.tsx
  • It's properly wrapped around the main <Outlet /> component in the layout, ensuring all routes are protected
  • No other instances of incorrect imports or improper usage were found
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any remaining .ts imports
echo "Checking for old .ts imports..."
rg "from.*preventExternalBrowser\.ts"

# Check component usage
echo "Checking PreventExternalBrowser usage..."
rg -A 5 "PreventExternalBrowser"

Length of output: 1740

apps/web/src/layout/GlobalLayout.tsx (1)

51-53: Verify routing behavior with wrapped Outlet.

The restructuring to wrap Outlet with PreventExternalBrowser means that browser detection logic will be applied to all routes. While this change appears intentional for handling Kakao browser login across all routes, please verify that:

  1. Navigation between routes still works as expected
  2. No unintended side effects occur in non-login routes
✅ Verification successful

Let me gather more information about the PreventExternalBrowser component to understand its implementation.


Based on the implementation details found, I can now provide the final response:

PreventExternalBrowser implementation is safe for routing

The PreventExternalBrowser component has a simple and focused implementation that only:

  1. Detects Kakao and Instagram browsers through user agent
  2. For Kakao browser: Opens the URL in system browser and shows a message
  3. For other browsers: Simply renders children without any interference

The component doesn't:

  • Manipulate routing or navigation
  • Block any route transitions
  • Interfere with the Outlet component's functionality

This structural change is safe and won't affect navigation between routes or cause any unintended side effects.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any route-specific handling in PreventExternalBrowser

# Test 1: Look for any route-specific logic in PreventExternalBrowser
ast-grep --pattern 'useLocation|useNavigate|useParams' 

# Test 2: Check for any conditional rendering based on routes
rg -A 5 'pathname|location.path' 

Length of output: 6782


Script:

#!/bin/bash
# Search for PreventExternalBrowser component implementation
rg -A 10 "PreventExternalBrowser" 

# Look for any browser detection or redirection logic
rg -A 10 "isKakaoBrowser|isBrowser|redirect"

Length of output: 15883

Copy link
Member

@leeminhee119 leeminhee119 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 !!

@klmhyeonwoo klmhyeonwoo merged commit f1dec8c into develop Nov 4, 2024
4 checks passed
@klmhyeonwoo klmhyeonwoo deleted the bugfix/409/externalBrowser branch November 4, 2024 12:41
@klmhyeonwoo
Copy link
Member Author

P태그로 구성된 메세지는 디자인 팀에서 리소스 받은 후 적용 예정입니다 : )

@coderabbitai coderabbitai bot mentioned this pull request Nov 9, 2024
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.

2 participants