Skip to content

Commit

Permalink
Merge pull request #419 from depromeet/bugfix/409/externalBrowser
Browse files Browse the repository at this point in the history
fix: #409 웹 환경에서 카카오 브라우저 로그인 시, 소셜 로그인 정책 우회
  • Loading branch information
klmhyeonwoo authored Nov 4, 2024
2 parents 07417c0 + 0487e44 commit f1dec8c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
1 change: 0 additions & 1 deletion apps/web/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ ReactDOM.createRoot(document.getElementById("root")!).render(
<Suspense fallback={<LoadingModal purpose={"데이터를 가져오고 있어요"} />}>
{/* <ReactQueryDevtools initialIsOpen={false} /> */}
{/* <DevTools /> */}

<Routers />
<Toast />
</Suspense>
Expand Down
17 changes: 0 additions & 17 deletions apps/web/src/helper/preventExternalBrowser.ts

This file was deleted.

19 changes: 19 additions & 0 deletions apps/web/src/helper/preventExternalBrowser.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Fragment, PropsWithChildren } from "react";

export function PreventExternalBrowser({ children }: PropsWithChildren) {
const agent = navigator.userAgent;
const URL = document.URL;
const isKakao = agent.includes("KAKAO");
const isInstagram = agent.includes("Instagram");

if (isKakao) {
window.open(`kakaotalk://web/openExternal?url=${encodeURIComponent(URL)}`);
return <span> 시스템 브라우저를 이용해주세요 </span>;
} else if (isInstagram) {
/**
* NOTE: 현재는 해당 인스타그램 인앱 탈출 코드가 작동하지 않는 것 같음
* 추후 카카오톡처럼 인스타그램 인앱 방지 분석 후 코드 추가 예정
*/
}
return <Fragment> {children} </Fragment>;
}
7 changes: 4 additions & 3 deletions apps/web/src/layout/GlobalLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useEffect } from "react";
import { Outlet, useLocation } from "react-router-dom";

import { Modal } from "@/component/common/Modal";
import { PreventExternalBrowser } from "@/helper/preventExternalBrowser.ts";
import { PreventExternalBrowser } from "@/helper/preventExternalBrowser.tsx";
import ChannelService from "@/lib/channel-talk/service";
import { useBridge } from "@/lib/provider/bridge-provider";

Expand Down Expand Up @@ -48,8 +48,9 @@ export default function GlobalLayout() {
`}
>
<Modal />
<PreventExternalBrowser />
<Outlet />
<PreventExternalBrowser>
<Outlet />
</PreventExternalBrowser>
</div>
);
}

0 comments on commit f1dec8c

Please sign in to comment.