diff --git a/src/components/Auth/LoginForm/FormAndButton.tsx b/src/components/Auth/LoginForm/FormAndButton.tsx index 6cd225ba..bf2d5eae 100644 --- a/src/components/Auth/LoginForm/FormAndButton.tsx +++ b/src/components/Auth/LoginForm/FormAndButton.tsx @@ -5,6 +5,7 @@ import { useAppDispatch, useAppSelector } from "app/store/Hooks"; import { signIn } from "app/store/ducks/auth/authThunk"; import useInput from "hooks/useInput"; import Loading from "components/Common/Loading"; +import { useHistory } from "react-router-dom"; const placeholder = { username: "사용자 이름", @@ -12,6 +13,8 @@ const placeholder = { }; export default function LoginFormAndButton() { + const history = useHistory(); + const [usernameInputProps, usernameIsValid, usernameIsFocus] = useInput( "", undefined, @@ -36,7 +39,9 @@ export default function LoginFormAndButton() { }), ); }; - requestSignIn(); + requestSignIn().then(() => { + history.push("/"); + }); }; return ( diff --git a/src/components/Auth/ResetPassword/ResetPasswordForm.tsx b/src/components/Auth/ResetPassword/ResetPasswordForm.tsx index 83ac270c..a745ee17 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"; @@ -72,6 +72,7 @@ const Container = styled.section` `; export default function ResetPasswordForm() { + const history = useHistory(); const { search } = useLocation(); const { username, code } = queryString.parse( search, @@ -105,7 +106,9 @@ export default function ResetPasswordForm() { username, newPassword: newPasswordInputProps.value, }), - ); + ).then(() => { + history.push("/"); + }); }; return ( diff --git a/src/components/Auth/SignUpForm/EmailConfirmForm.tsx b/src/components/Auth/SignUpForm/EmailConfirmForm.tsx index fe75eb35..7c0d8040 100644 --- a/src/components/Auth/SignUpForm/EmailConfirmForm.tsx +++ b/src/components/Auth/SignUpForm/EmailConfirmForm.tsx @@ -11,6 +11,7 @@ import { authAction } from "app/store/ducks/auth/authSlice"; import { signIn } from "app/store/ducks/auth/authThunk"; import { useState } from "react"; import Loading from "components/Common/Loading"; +import { useHistory } from "react-router-dom"; const Container = styled.div` .form-description { @@ -71,6 +72,7 @@ const messageImage: CommonType.ImageProps = { }; export default function EmailConfirmForm() { + const history = useHistory(); const userInput = useAppSelector((state) => state.auth.signUpUserData); const dispatch = useAppDispatch(); const [errorMessage, setErrorMessage] = useState(""); @@ -129,7 +131,9 @@ export default function EmailConfirmForm() { username: userInput.username, password: userInput.password, }), - ); + ).then(() => { + history.push("/"); + }); } else if (status === 200 && !data) { setErrorMessage(message); // 인증코드가 다를 경우, 200번대가 아니라 400번대가 더 적합할 거 같음(사용자 입력에러니까)