Skip to content

Commit b4f0bb8

Browse files
fix(auth): add session validation and redirect for unauthorized access
1 parent 7b5067c commit b4f0bb8

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/app/lists/page.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {
44
fetchLikeMembers,
55
} from "../actions/likeActions";
66
import ListsTab from "./ListsTab";
7+
import { auth } from "@/auth";
8+
import { redirect } from "next/navigation";
79

810
export const dynamic = "force-dynamic";
911

@@ -12,6 +14,12 @@ export default async function ListsPage({
1214
}: {
1315
searchParams: Promise<{ type?: string }>;
1416
}) {
17+
const session = await auth();
18+
19+
if (!session?.user?.id) {
20+
redirect("/login");
21+
}
22+
1523
const params = await searchParams;
1624
const type =
1725
params.type === "source" ||

src/app/members/page.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@ import PaginationComponent from '@/components/PaginationComponent';
66
import Filters from '@/components/navbar/Filters';
77
import { GetMemberParams } from '@/types';
88
import EmptyState from '@/components/EmptyState';
9+
import { auth } from '@/auth';
10+
import { redirect } from 'next/navigation';
911

1012
export default async function MembersPage({searchParams,}:{
1113
searchParams: Promise<GetMemberParams>;
1214
}) {
15+
const session = await auth();
16+
17+
if (!session?.user?.id) {
18+
redirect('/login');
19+
}
20+
1321
const params = await searchParams;
1422

1523
const {items:members, totalCount}= await getMembers(params);

0 commit comments

Comments
 (0)