Skip to content

Commit 07da3ba

Browse files
BryanTaylanDVidal1205
authored andcommitted
Add authentication to forms edit page
1 parent ea2bd79 commit 07da3ba

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1+
import { auth } from "@forge/auth";
12
import FormsClient from "../../_components/admin/forms/homepage";
3+
import { SIGN_IN_PATH } from "~/consts";
4+
import { redirect } from "next/navigation";
5+
import { api } from "~/trpc/server";
26

37
export const metadata = {
48
title: "Forms",
59
};
610

7-
export default function Page() {
11+
export default async function Page() {
12+
const session = await auth();
13+
if (!session) {
14+
redirect(SIGN_IN_PATH);
15+
}
16+
17+
const isAdmin = await api.auth.getAdminStatus();
18+
if (!isAdmin) {
19+
redirect("/");
20+
}
21+
822
return <FormsClient />;
923
}

0 commit comments

Comments
 (0)