From b426f7ee11525fb88cde48c04c035dd12b0cc3e8 Mon Sep 17 00:00:00 2001 From: lim396 <90199432+lim396@users.noreply.github.com> Date: Sat, 9 Mar 2024 17:04:59 +0900 Subject: [PATCH] [frontend] Fixed to call notFound function instead of throwing Error object (#307) --- frontend/app/room/[id]/page.tsx | 13 ++++++++++++- frontend/app/room/[id]/room-detail.tsx | 8 ++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/frontend/app/room/[id]/page.tsx b/frontend/app/room/[id]/page.tsx index 919a4a90..2dfef4b8 100644 --- a/frontend/app/room/[id]/page.tsx +++ b/frontend/app/room/[id]/page.tsx @@ -3,6 +3,7 @@ import { Separator } from "@/components/ui/separator"; import { notFound } from "next/navigation"; import MessageArea from "./message-area"; import RoomDetail from "./room-detail"; +import { getCurrentUserId } from "@/app/lib/session"; export default async function Page({ params: { id }, @@ -18,12 +19,22 @@ export default async function Page({ } const messages = await getMessages(roomId); const allUsers = await getUsers(); + const currentUserId = await getCurrentUserId(); + const me = room.users.find((u) => u.userId === currentUserId); + if (!me) { + notFound(); + } return ( <>