diff --git a/src/components/message/MessageModal.js b/src/components/message/MessageModal.js index c10c8095..334cc590 100644 --- a/src/components/message/MessageModal.js +++ b/src/components/message/MessageModal.js @@ -8,6 +8,7 @@ import { } from '@component/ui'; import { useHistory } from 'react-router-dom'; import { closeModal } from '@src/redux/features/comn/message/messageSlice'; +import { ERROR_MESSAGE } from '@src/configs/msgConst'; export const MessageModal = () => { const dispatch = useDispatch(); @@ -17,6 +18,9 @@ export const MessageModal = () => { ); const handlerClose = () => { + if (body === ERROR_MESSAGE) { + history.replace('/account/login'); + } dispatch(closeModal()); if (isHistoryBack) { diff --git a/src/redux/features/account/auth/authThunk.ts b/src/redux/features/account/auth/authThunk.ts index f4c912d7..dc180e5e 100644 --- a/src/redux/features/account/auth/authThunk.ts +++ b/src/redux/features/account/auth/authThunk.ts @@ -55,11 +55,10 @@ export const setLogin = createAsyncThunk( } catch (error: any) { thunkAPI.dispatch( openModal({ - header: '로그인 실패', - body: error + header: ERROR_TITLE, + body: ERROR_MESSAGE }) ); - return thunkAPI.rejectWithValue(error); } } ); diff --git a/src/router/hoc/authenticationCheck.tsx b/src/router/hoc/authenticationCheck.tsx index 0a7042a1..4aeb6e0e 100644 --- a/src/router/hoc/authenticationCheck.tsx +++ b/src/router/hoc/authenticationCheck.tsx @@ -4,6 +4,13 @@ import { useSelector, useDispatch } from '@src/redux/store'; import { checkToken } from '@src/redux/features/account/auth/authThunk'; import { ICheckAuthencationRs } from '@src/redux/features/account/auth/authState'; import { clientDispatchTopMenu } from '@src/redux/features/layout/layoutSlice'; +import { openModal } from '@src/redux/features/comn/message/messageSlice'; +import { + COOKIE_ACCESS_TOKEN, + COOKIE_REFRESH_TOKEN, + cookieStorage +} from '@src/utility/authService/cookie'; +import { ERROR_TITLE, ERROR_MESSAGE } from '@src/configs/msgConst'; interface IOption { authRoute?: boolean; @@ -24,12 +31,16 @@ export default function (SpecificComponent: ReactNode, option: IOption) { ) => JSX.Element; useEffect(() => { - dispatch(checkToken() as any).then(({ payload: { result } }) => { + if (props.match.path === '/account/login') { + setIsRender(true); + return; + } + dispatch(checkToken() as any).then(({ payload }) => { try { // 로그인 해야만 접근 가능한 페이지인지 체크하는 옵션 const { authRoute } = option; - if (!result) { + if (!payload?.result) { if (authRoute) { props.history.replace('/account/login'); return; @@ -42,9 +53,7 @@ export default function (SpecificComponent: ReactNode, option: IOption) { } } setIsRender(true); - } catch (error) { - // props.history.replace('/account/login'); - } + } catch (error) {} }); return () => { setIsRender(false);