From 8fa18b0e56be84c146cf6b95dc963d8a64e43450 Mon Sep 17 00:00:00 2001 From: suhwa Date: Tue, 16 Aug 2022 18:25:13 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=EB=B9=84=EB=B0=80=EB=B2=88=ED=98=B8?= =?UTF-8?q?=20=EC=9E=AC=EC=84=A4=EC=A0=95=20=EC=84=B1=EA=B3=B5=20=EC=8B=9C?= =?UTF-8?q?=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=ED=9B=84,=20home=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 로그인 후, 없는 route에 대해서 /로 리다이렉트 시킴 --- src/Routes.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Routes.tsx b/src/Routes.tsx index 394c6d61..96475392 100644 --- a/src/Routes.tsx +++ b/src/Routes.tsx @@ -70,6 +70,7 @@ const AuthedContainer = () => { {/* Direct */} + {/* 404 페이지 필요*/} ); From a3a2ecfed156ceac9aecb8c1f2c15dc572e2f387 Mon Sep 17 00:00:00 2001 From: suhwa Date: Tue, 16 Aug 2022 18:44:16 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=EB=B9=84=EB=B0=80=EB=B2=88=ED=98=B8?= =?UTF-8?q?=20=EC=9E=AC=EC=84=A4=EC=A0=95=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EB=A7=8C=EB=A3=8C=EA=B8=B0=EA=B0=84=EC=9D=B4=20=EC=A7=80?= =?UTF-8?q?=EB=82=AC=EC=9D=84=20=EB=95=8C=20error=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 비밀번호 재설정 신청 후, 일정시간만 재설정 할 수 있는 페이지 이동 유효함 --- src/app/store/ducks/auth/authSlice.ts | 4 ---- src/app/store/ducks/auth/authThunk.ts | 24 +++++++------------ .../Auth/ResetPassword/ResetPasswordForm.tsx | 9 +++++-- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/app/store/ducks/auth/authSlice.ts b/src/app/store/ducks/auth/authSlice.ts index 2e4b6a60..41071cb9 100644 --- a/src/app/store/ducks/auth/authSlice.ts +++ b/src/app/store/ducks/auth/authSlice.ts @@ -4,7 +4,6 @@ import { getUserInfo, signIn, resetPassword, - checkCurrentURL, signInUseCode, logout, } from "./authThunk"; @@ -125,9 +124,6 @@ const authSlice = createSlice({ .addCase(resetPassword.rejected, (state) => { state.errorMessage = `전에 사용한 적 없는 새로운 비밀번호를 만드세요.`; }) - .addCase(checkCurrentURL.rejected, (state) => { - // 유효하지 않은 url ** - }) .addCase(logout.fulfilled, (state) => { state.isLogin = false; }); diff --git a/src/app/store/ducks/auth/authThunk.ts b/src/app/store/ducks/auth/authThunk.ts index 24368e4f..782c3d03 100644 --- a/src/app/store/ducks/auth/authThunk.ts +++ b/src/app/store/ducks/auth/authThunk.ts @@ -63,22 +63,14 @@ export const getUserInfo = createAsyncThunk( export const checkCurrentURL = createAsyncThunk< void, { code: string; username: string } ->("auth/checkResetPassword", async (payload, ThunkOptions) => { - try { - const config = { - params: { - code: payload.code, - username: payload.username, - }, - }; - const { data } = await customAxios.get( - `/accounts/password/reset`, - config, - ); - console.log(data); - } catch (error) { - throw ThunkOptions.rejectWithValue(error); - } +>("auth/checkResetPassword", async (payload) => { + const config = { + params: { + code: payload.code, + username: payload.username, + }, + }; + await customAxios.get(`/accounts/password/reset`, config); }); export const resetPassword = createAsyncThunk< diff --git a/src/components/Auth/ResetPassword/ResetPasswordForm.tsx b/src/components/Auth/ResetPassword/ResetPasswordForm.tsx index 83ac270c..130977f8 100644 --- a/src/components/Auth/ResetPassword/ResetPasswordForm.tsx +++ b/src/components/Auth/ResetPassword/ResetPasswordForm.tsx @@ -1,4 +1,4 @@ -import { useLocation } from "react-router-dom"; +import { useHistory, useLocation } from "react-router-dom"; import queryString from "query-string"; import HeaderBeforeLogin from "./HeaderBeforeLogin"; import ContentBox from "components/Common/ContentBox"; @@ -77,6 +77,7 @@ export default function ResetPasswordForm() { search, ) as AuthType.resetPasswordQuery; const dispatch = useAppDispatch(); + const history = useHistory(); const { errorMessage } = useAppSelector((state) => state.auth); const [newPasswordInputProps, newPasswordIsValid] = useInput( @@ -92,7 +93,11 @@ export default function ResetPasswordForm() { ); useEffect(() => { - dispatch(checkCurrentURL({ code, username })); + dispatch(checkCurrentURL({ code, username })) + .unwrap() + .catch(() => { + history.push("/error"); + }); }, []); const resetPasswordClickHandler = (