diff --git a/src/app/(api)/auth/activate/[token]/route.ts b/src/app/(api)/auth/activate/[token]/route.ts index cd673f96..48eb8eba 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('token', res.secret); + (await cookies()).set('auth', 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 819c6b25..957ea345 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('token', res.secret, { + (await cookies()).set('auth', 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 2c3a8876..874e066d 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('token'); + (await cookies()).delete('auth'); 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 077156ba..80f0ccd2 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('token'); + const auth = await getCookie('auth'); 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 bed5307a..5a51713f 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('token'); + const auth = await getCookie('auth'); 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 0a10bfa6..8d996ea1 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('token'); + const auth = await getCookie('auth'); 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 10928886..78190042 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('token'); + const auth = await getCookie('auth'); auth && (await prefetchFollowingHistory()); diff --git a/src/app/(pages)/collections/(collections)/page.tsx b/src/app/(pages)/collections/(collections)/page.tsx index 9cc91289..ade6f283 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('token'); + const auth = await getCookie('auth'); 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 2f7bd422..c88dea8c 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('token'); + const auth = await getCookie('auth'); 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 5f726500..196437f7 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('token', data.secret); + await setCookie('auth', 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 548b0f01..7cc986a8 100644 --- a/src/features/modals/auth-modal/password-confirm-form.tsx +++ b/src/features/modals/auth-modal/password-confirm-form.tsx @@ -33,7 +33,7 @@ const Component = () => { const router = useRouter(); const { closeModal } = useModalContext(); - const token = searchParams.get('token')!; + const token = searchParams.get('auth')!; const form = useForm>({ resolver: zodResolver(formSchema), @@ -48,7 +48,7 @@ const Component = () => { }, }), onSuccess: async (data) => { - await setCookie('token', data.secret); + await setCookie('auth', 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 69a21509..48e3947f 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('token', data.secret); + await setCookie('auth', data.secret); closeModal(); router.refresh(); diff --git a/src/services/api/fetchRequest.ts b/src/services/api/fetchRequest.ts index de6c89f8..f53b359b 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('token')))!; + headers.auth = (options.auth || (await getCookie('auth')))!; } else { if (process.env.NEXT_PUBLIC_DEV === 'true') { - headers.auth = options.auth || (await getCookie('token'))!; + headers.auth = options.auth || (await getCookie('auth'))!; } } diff --git a/src/services/hooks/auth/use-session.ts b/src/services/hooks/auth/use-session.ts index 6c9a8aeb..1efa15f9 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('token'); + await deleteCookie('auth'); window.location.reload(); };