diff --git a/src/pages/auth/SignUp.tsx b/src/pages/auth/SignUp.tsx
index 3c989445..bd21425c 100644
--- a/src/pages/auth/SignUp.tsx
+++ b/src/pages/auth/SignUp.tsx
@@ -1,4 +1,5 @@
-import { useState } from 'react';
+import { useState, useEffect } from 'react';
+import { useRouter } from 'next/router';
import Image from 'next/image';
import Link from 'next/link';
import { zodResolver } from '@hookform/resolvers/zod';
@@ -11,6 +12,14 @@ import useRegisterMutation from '@/hooks/useRegisterMutation';
export default function SignUp() {
const [focusedField, setFocusedField] = useState
(null);
+ const router = useRouter();
+
+ useEffect(() => {
+ const accessToken = localStorage.getItem('accessToken');
+ if (accessToken) {
+ router.push('/epigrams');
+ }
+ }, [router]);
const form = useForm({
resolver: zodResolver(PostSignUpRequest),
diff --git a/src/pages/auth/callback/google/index.ts b/src/pages/auth/callback/google/index.ts
index 8b9275e7..320477e4 100644
--- a/src/pages/auth/callback/google/index.ts
+++ b/src/pages/auth/callback/google/index.ts
@@ -1,11 +1,11 @@
import { useEffect } from 'react';
import { useSearchParams } from 'next/navigation';
-import useGoogleLogin from '@/hooks/useGoogleLogin'; // useGoogleLogin 훅을 가져옵니다
+import useGoogleLogin from '@/hooks/useGoogleLogin';
export default function Google() {
const searchParams = useSearchParams();
- const code = searchParams.get('code'); // URL에서 'code' 값을 가져옵니다
- const { mutate: login } = useGoogleLogin(); // useGoogleLogin 훅에서 mutate 함수를 가져옵니다
+ const code = searchParams.get('code');
+ const { mutate: login } = useGoogleLogin();
useEffect(() => {
if (code) {
@@ -15,6 +15,4 @@ export default function Google() {
console.log('No code found in URL parameters'); // code가 없을 때 콘솔에 출력
}
}, [code, login]);
-
- return null; // 컴포넌트가 UI를 렌더링하지 않음
}
diff --git a/src/pages/auth/redirect/google-callback/index.ts b/src/pages/auth/redirect/google-callback/index.ts
deleted file mode 100644
index 1f925901..00000000
--- a/src/pages/auth/redirect/google-callback/index.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { useEffect } from 'react';
-import { useSearchParams } from 'next/navigation';
-import useGoogleLogin from '@/hooks/useGoogleLogin';
-
-export default function Google() {
- const searchParams = useSearchParams();
- const code = searchParams.get('code');
- const { mutate: login } = useGoogleLogin();
-
- useEffect(() => {
- if (code) {
- login(code);
- } else {
- /* eslint-disable no-console */
- console.log(code); // code가 없을 때 콘솔에 출력
- }
- }, [code, login]);
-}
-
-// code가 없는 경우의 예시 http://localhost:3000/auth/redirect/kakao
-// 토스트로 에러 메시지 띄우고, 로그인 페이지로 리다이렉트