This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { getServerSession } from "next-auth";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import InFolder from "./InFolder";
|
||||
import { getOwnerByFolderId } from "@/lib/services/folderService";
|
||||
export default async function FoldersPage({
|
||||
@@ -10,12 +11,14 @@ export default async function FoldersPage({
|
||||
const session = await getServerSession();
|
||||
const { folder_id } = await params;
|
||||
const id = Number(folder_id);
|
||||
const t = await getTranslations("folders.folder_id");
|
||||
|
||||
if (!id) {
|
||||
redirect("/folders");
|
||||
}
|
||||
if (!session?.user?.name) redirect(`/login?redirect=/folders/${id}`);
|
||||
if ((await getOwnerByFolderId(id)) !== session.user.name) {
|
||||
return "you are not the owner of this folder";
|
||||
return <p>{t("unauthorized")}</p>;
|
||||
}
|
||||
return <InFolder folderId={id} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user