Skip to content

Commit

Permalink
fix: revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
olexh committed Dec 28, 2024
1 parent 5b7fd10 commit b3c476d
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/app/(api)/auth/activate/[token]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
2 changes: 1 addition & 1 deletion src/app/(api)/auth/google/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/(api)/auth/logout/route.ts
Original file line number Diff line number Diff line change
@@ -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}`);
}
2 changes: 1 addition & 1 deletion src/app/(pages)/(content)/anime/[slug]/layout.queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
Expand Down
2 changes: 1 addition & 1 deletion src/app/(pages)/(content)/manga/[slug]/layout.queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
Expand Down
2 changes: 1 addition & 1 deletion src/app/(pages)/(content)/novel/[slug]/layout.queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
Expand Down
2 changes: 1 addition & 1 deletion src/app/(pages)/(user)/u/[username]/history/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface Props {
const FollowingHistoryPage: FC<Props> = async (props) => {
const searchParams = await props.searchParams;
const queryClient = getQueryClient();
const auth = await getCookie('token');
const auth = await getCookie('auth');

auth && (await prefetchFollowingHistory());

Expand Down
2 changes: 1 addition & 1 deletion src/app/(pages)/collections/(collections)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const CollectionsPage: FC<Props> = async (props) => {
}

const queryClient = await getQueryClient();
const auth = await getCookie('token');
const auth = await getCookie('auth');

const params = { page: Number(page), sort };

Expand Down
2 changes: 1 addition & 1 deletion src/features/common/session-manager.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion src/features/modals/auth-modal/login-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/features/modals/auth-modal/password-confirm-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
Expand All @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/features/modals/auth-modal/signup-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions src/services/api/fetchRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'))!;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/hooks/auth/use-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const useSession = () => {
});

const logout = async () => {
await deleteCookie('token');
await deleteCookie('auth');
window.location.reload();
};

Expand Down

0 comments on commit b3c476d

Please sign in to comment.