@@ -45,7 +72,7 @@ const SigninForm = () => {
-
);
};
diff --git a/src/constants/auth.ts b/src/constants/auth.ts
index 3e8ddde5..b85b75b6 100644
--- a/src/constants/auth.ts
+++ b/src/constants/auth.ts
@@ -1,2 +1,10 @@
-export const ACCESS_TOKEN_EXPIRED_TIME = new Date(new Date().getTime() + 25 * 60 * 1000);
-export const REFRESH_TOKEN_EXPIRED_TIME = 13;
+/**
+ * 25분
+ * SS * MM
+ */
+export const ACCESS_TOKEN_EXPIRED_TIME = 60 * 25;
+/**
+ * 13일
+ * SS * MM * HH * DD
+ */
+export const REFRESH_TOKEN_EXPIRED_TIME = 60 * 60 * 24 * 13;
diff --git a/src/constants/inputValidation.ts b/src/constants/inputValidation.ts
index 7600efdd..5f15ef8d 100644
--- a/src/constants/inputValidation.ts
+++ b/src/constants/inputValidation.ts
@@ -32,3 +32,10 @@ export const REGEX = {
password: /^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d]{8,15}$/,
textarea: /\n/g,
};
+
+export const API_ERROR_MESSAGE = {
+ signin: {
+ 404: '회원가입을 해주세요',
+ 400: '이메일과 비밀번호를 확인해주세요',
+ },
+};
diff --git a/src/constants/pagePaths.ts b/src/constants/pagePaths.ts
index cee25e8d..e24aa1c8 100644
--- a/src/constants/pagePaths.ts
+++ b/src/constants/pagePaths.ts
@@ -3,4 +3,5 @@ export const PAGE_PATHS = {
mypage: '/mypage',
signup: '/signup',
signin: '/signin',
+ mainList: '/league-of-legends',
};
diff --git a/src/hooks/useSignin.ts b/src/hooks/useSignin.ts
index cf338e1e..640e7235 100644
--- a/src/hooks/useSignin.ts
+++ b/src/hooks/useSignin.ts
@@ -1,28 +1,18 @@
import { useMutation } from '@tanstack/react-query';
-import Cookies from 'js-cookie';
import { Auth } from '@/apis/auth';
-import { ACCESS_TOKEN_EXPIRED_TIME, REFRESH_TOKEN_EXPIRED_TIME } from '@/constants';
+import { setAuthCookie } from '@/utils';
import useUserStore from '@/stores/useUserStore';
import { Account } from '@/types';
-const useSignin = (value: Account) => {
+const useSignin = () => {
const { error, mutate } = useMutation({
- mutationFn: () => Auth.signin(value),
+ mutationFn: (value: Account) => Auth.signin(value),
onSuccess(data) {
const { accessToken, refreshToken, user } = data.data;
- Cookies.set('accessToken', accessToken, {
- expires: ACCESS_TOKEN_EXPIRED_TIME,
- secure: true,
- sameSite: 'strict',
- });
- Cookies.set('refreshToken', refreshToken, {
- expires: REFRESH_TOKEN_EXPIRED_TIME,
- secure: true,
- sameSite: 'strict',
- });
+ setAuthCookie(null, accessToken, refreshToken);
useUserStore.setState({ user: user });
},
});
diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx
index 4bfca925..962900a4 100644
--- a/src/pages/_app.tsx
+++ b/src/pages/_app.tsx
@@ -1,6 +1,6 @@
import type { AppProps } from 'next/app';
-import { QueryClientProvider } from '@tanstack/react-query';
+import { HydrationBoundary, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import Modal from 'react-modal';
@@ -21,12 +21,14 @@ export default function App({ Component, pageProps }: AppProps) {
return (