Browse Source

token 검증 로직 수정(token 없을시 검증 api 요청 제외)

master
김장현 3 weeks ago
parent
commit
70b863cab5
  1. 72
      src/router/hoc/authenticationCheck.tsx

72
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);
};

Loading…
Cancel
Save