From 70b863cab50179ef862efa4483836bb1fd8e7b71 Mon Sep 17 00:00:00 2001 From: JANGHYUNn Date: Thu, 29 Aug 2024 14:34:41 +0900 Subject: [PATCH] =?UTF-8?q?token=20=EA=B2=80=EC=A6=9D=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EC=88=98=EC=A0=95(token=20=EC=97=86=EC=9D=84=EC=8B=9C=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9D=20api=20=EC=9A=94=EC=B2=AD=20=EC=A0=9C?= =?UTF-8?q?=EC=99=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/hoc/authenticationCheck.tsx | 72 ++++++++++---------------- 1 file changed, 28 insertions(+), 44 deletions(-) diff --git a/src/router/hoc/authenticationCheck.tsx b/src/router/hoc/authenticationCheck.tsx index 4f2e19e0..8d73848e 100644 --- a/src/router/hoc/authenticationCheck.tsx +++ b/src/router/hoc/authenticationCheck.tsx @@ -25,59 +25,43 @@ export default function (SpecificComponent: ReactNode, option: IOption) { props: IProps ) => JSX.Element; - // useEffect(() => { - // if (user?.cptAuthCode === 'DF0002') { - // const pathname = history.location.pathname; - - // if ( - // !( - // pathname == '/operation/approvals' || - // pathname == '/rightMenu' || - // pathname == 'control/approvals' || - // pathname == 'control/rightMenu' - // ) - // ) { - // // id 나누면 주석 풀 것!!! - // // props.history.replace('/operation/approvals'); - // return; - // } - // } - // }, [user]); - useEffect(() => { // if (props.match.path === '/account/login') { // setIsRender(true); // return; // } - dispatch(checkToken() as any).then(({ payload }) => { - try { - // 로그인 해야만 접근 가능한 페이지인지 체크하는 옵션 - const { authRoute } = option; + if (getDecodeToken()) { + dispatch(checkToken() as any).then(({ payload }) => { + try { + // 로그인 해야만 접근 가능한 페이지인지 체크하는 옵션 + const { authRoute } = option; - if (!payload?.result) { - if (authRoute) { - props.history.replace('/account/login'); - return; - } - } else { - if (!authRoute) { - const decodeToken = getDecodeToken(); - if (decodeToken) { - if (decodeToken.cptAuthCode === 'DF0002') { - props.history.replace('/control/approvals'); - } else if (decodeToken.cptAuthCode === 'DF0002-1') { - props.history.replace('/operation/approvals'); - } else { - localStorage.setItem('topMenuCd', '/'); - dispatch(clientDispatchTopMenu('/')); - props.history.replace('/control'); + if (!payload?.result) { + if (authRoute) { + props.history.replace('/account/login'); + return; + } + } else { + if (!authRoute) { + const decodeToken = getDecodeToken(); + if (decodeToken) { + if (decodeToken.cptAuthCode === 'DF0002') { + props.history.replace('/control/approvals'); + } else if (decodeToken.cptAuthCode === 'DF0002-1') { + props.history.replace('/operation/approvals'); + } else { + localStorage.setItem('topMenuCd', '/'); + dispatch(clientDispatchTopMenu('/')); + props.history.replace('/control'); + } } } } - } - setIsRender(true); - } catch (error) {} - }); + } catch (error) {} + }); + } + setIsRender(true); + return () => { setIsRender(false); };