Skip to content

Commit 491a484

Browse files
committed
Feat:로그인 상태 로그인 페이지 접속 시 랜딩 페이지로 리다이렉트
1 parent 09d63a8 commit 491a484

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pages/login/index.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import SnsLogin from "@/components/Auth/SnsLogin";
44
import SubmitButton from "@/components/SubMitButton";
55
import AuthLayout from "@/components/Layout/AuthLayout";
66
import Link from "next/link";
7+
import { useRouter } from "next/router";
8+
import useAuthStore from "@/store/useAuthStore";
9+
import { useEffect } from "react";
710

811
const LoginPage = () => {
912
const {
@@ -15,6 +18,14 @@ const LoginPage = () => {
1518
isFormInvalid,
1619
isLoading,
1720
} = useForm(false);
21+
const router = useRouter();
22+
const { user } = useAuthStore();
23+
24+
useEffect(() => {
25+
if (user) {
26+
router.replace("/");
27+
}
28+
}, [user, router]);
1829

1930
return (
2031
<div className="bg-gray100 min-h-screen">

0 commit comments

Comments
 (0)