diff --git a/src/app/(api)/auth/activate/[token]/route.ts b/src/app/(api)/auth/activate/[token]/route.ts index 48eb8eba..cd673f96 100644 --- a/src/app/(api)/auth/activate/[token]/route.ts +++ b/src/app/(api)/auth/activate/[token]/route.ts @@ -15,7 +15,7 @@ export async function GET( try { const res = await activation({ params: { token } }); - (await cookies()).set('auth', res.secret); + (await cookies()).set('token', res.secret); } catch (e) { if ('code' in (e as API.Error)) { if ((e as API.Error).code === 'auth-modal:activation_expired') { diff --git a/src/app/(api)/auth/google/route.ts b/src/app/(api)/auth/google/route.ts index 957ea345..819c6b25 100644 --- a/src/app/(api)/auth/google/route.ts +++ b/src/app/(api)/auth/google/route.ts @@ -18,7 +18,7 @@ export async function GET(request: Request) { }, }); - (await cookies()).set('auth', res.secret, { + (await cookies()).set('token', res.secret, { maxAge: 60 * 60 * 24 * 7, }); } catch (e) { diff --git a/src/app/(api)/auth/logout/route.ts b/src/app/(api)/auth/logout/route.ts index 874e066d..2c3a8876 100644 --- a/src/app/(api)/auth/logout/route.ts +++ b/src/app/(api)/auth/logout/route.ts @@ -1,7 +1,7 @@ import { cookies } from 'next/headers'; export async function GET() { - (await cookies()).delete('auth'); + (await cookies()).delete('token'); return Response.redirect(`${process.env.SITE_URL}`); } diff --git a/src/app/(pages)/(content)/anime/[slug]/layout.queries.ts b/src/app/(pages)/(content)/anime/[slug]/layout.queries.ts index 80f0ccd2..077156ba 100644 --- a/src/app/(pages)/(content)/anime/[slug]/layout.queries.ts +++ b/src/app/(pages)/(content)/anime/[slug]/layout.queries.ts @@ -13,7 +13,7 @@ interface Props { } const prefetchQueries = async ({ params: { slug } }: Props) => { - const auth = await getCookie('auth'); + const auth = await getCookie('token'); await Promise.all([ prefetchCharacters({ slug }), diff --git a/src/app/(pages)/(content)/manga/[slug]/layout.queries.ts b/src/app/(pages)/(content)/manga/[slug]/layout.queries.ts index 5a51713f..bed5307a 100644 --- a/src/app/(pages)/(content)/manga/[slug]/layout.queries.ts +++ b/src/app/(pages)/(content)/manga/[slug]/layout.queries.ts @@ -10,7 +10,7 @@ interface Props { } const prefetchQueries = async ({ params: { slug } }: Props) => { - const auth = await getCookie('auth'); + const auth = await getCookie('token'); await Promise.all([ prefetchMangaCharacters({ slug }), diff --git a/src/app/(pages)/(content)/novel/[slug]/layout.queries.ts b/src/app/(pages)/(content)/novel/[slug]/layout.queries.ts index 8d996ea1..0a10bfa6 100644 --- a/src/app/(pages)/(content)/novel/[slug]/layout.queries.ts +++ b/src/app/(pages)/(content)/novel/[slug]/layout.queries.ts @@ -10,7 +10,7 @@ interface Props { } const prefetchQueries = async ({ params: { slug } }: Props) => { - const auth = await getCookie('auth'); + const auth = await getCookie('token'); await Promise.all([ prefetchNovelCharacters({ slug }), diff --git a/src/app/(pages)/(user)/u/[username]/history/page.tsx b/src/app/(pages)/(user)/u/[username]/history/page.tsx index 78190042..10928886 100644 --- a/src/app/(pages)/(user)/u/[username]/history/page.tsx +++ b/src/app/(pages)/(user)/u/[username]/history/page.tsx @@ -21,7 +21,7 @@ interface Props { const FollowingHistoryPage: FC = async (props) => { const searchParams = await props.searchParams; const queryClient = getQueryClient(); - const auth = await getCookie('auth'); + const auth = await getCookie('token'); auth && (await prefetchFollowingHistory()); diff --git a/src/app/(pages)/collections/(collections)/page.tsx b/src/app/(pages)/collections/(collections)/page.tsx index ade6f283..9cc91289 100644 --- a/src/app/(pages)/collections/(collections)/page.tsx +++ b/src/app/(pages)/collections/(collections)/page.tsx @@ -46,7 +46,7 @@ const CollectionsPage: FC = async (props) => { } const queryClient = await getQueryClient(); - const auth = await getCookie('auth'); + const auth = await getCookie('token'); const params = { page: Number(page), sort }; diff --git a/src/features/common/session-manager.component.tsx b/src/features/common/session-manager.component.tsx index c88dea8c..2f7bd422 100644 --- a/src/features/common/session-manager.component.tsx +++ b/src/features/common/session-manager.component.tsx @@ -11,7 +11,7 @@ interface Props extends PropsWithChildren {} const SessionManager = async ({ children }: Props) => { const queryClient = await getQueryClient(); - const auth = await getCookie('auth'); + const auth = await getCookie('token'); auth && (await queryClient.prefetchQuery({ diff --git a/src/features/modals/auth-modal/login-form.tsx b/src/features/modals/auth-modal/login-form.tsx index 196437f7..5f726500 100644 --- a/src/features/modals/auth-modal/login-form.tsx +++ b/src/features/modals/auth-modal/login-form.tsx @@ -37,7 +37,7 @@ const Component = () => { const mutation = useMutation({ mutationFn: login, onSuccess: async (data) => { - await setCookie('auth', data.secret); + await setCookie('token', data.secret); form.reset(); closeModal(); router.refresh(); diff --git a/src/features/modals/auth-modal/password-confirm-form.tsx b/src/features/modals/auth-modal/password-confirm-form.tsx index 86aa9241..548b0f01 100644 --- a/src/features/modals/auth-modal/password-confirm-form.tsx +++ b/src/features/modals/auth-modal/password-confirm-form.tsx @@ -4,7 +4,6 @@ import { zodResolver } from '@hookform/resolvers/zod'; import { useMutation } from '@tanstack/react-query'; import { useRouter, useSearchParams } from 'next/navigation'; import { useSnackbar } from 'notistack'; -import React from 'react'; import { useForm } from 'react-hook-form'; import FormInput from '@/components/form/form-input'; @@ -49,7 +48,7 @@ const Component = () => { }, }), onSuccess: async (data) => { - await setCookie('auth', data.secret); + await setCookie('token', data.secret); form.reset(); closeModal(); router.push('/anime'); diff --git a/src/features/modals/auth-modal/signup-form.tsx b/src/features/modals/auth-modal/signup-form.tsx index 48e3947f..69a21509 100644 --- a/src/features/modals/auth-modal/signup-form.tsx +++ b/src/features/modals/auth-modal/signup-form.tsx @@ -55,7 +55,7 @@ const Component = () => { captcha: String(captchaRef.current?.getResponse()), }), onSuccess: async (data) => { - await setCookie('auth', data.secret); + await setCookie('token', data.secret); closeModal(); router.refresh(); diff --git a/src/services/api/fetchRequest.ts b/src/services/api/fetchRequest.ts index f53b359b..de6c89f8 100644 --- a/src/services/api/fetchRequest.ts +++ b/src/services/api/fetchRequest.ts @@ -64,10 +64,10 @@ async function buildHeaders( // Add auth header for server-side requests if (typeof window === 'undefined') { - headers.auth = (options.auth || (await getCookie('auth')))!; + headers.auth = (options.auth || (await getCookie('token')))!; } else { if (process.env.NEXT_PUBLIC_DEV === 'true') { - headers.auth = options.auth || (await getCookie('auth'))!; + headers.auth = options.auth || (await getCookie('token'))!; } } diff --git a/src/services/hooks/auth/use-session.ts b/src/services/hooks/auth/use-session.ts index 1efa15f9..6c9a8aeb 100644 --- a/src/services/hooks/auth/use-session.ts +++ b/src/services/hooks/auth/use-session.ts @@ -13,7 +13,7 @@ const useSession = () => { }); const logout = async () => { - await deleteCookie('auth'); + await deleteCookie('token'); window.location.reload(); };