2024-11-26 20:30:52 -05:00
|
|
|
import { verifySession } from "@app/lib/auth/verifySession";
|
2024-11-02 15:44:48 -04:00
|
|
|
import { Metadata } from "next";
|
2024-11-26 20:30:52 -05:00
|
|
|
import { redirect } from "next/navigation";
|
|
|
|
import { cache } from "react";
|
2024-11-02 15:44:48 -04:00
|
|
|
|
|
|
|
export const metadata: Metadata = {
|
|
|
|
title: `Setup - Pangolin`,
|
2024-12-21 14:11:10 -05:00
|
|
|
description: ""
|
2024-11-02 15:44:48 -04:00
|
|
|
};
|
|
|
|
|
2024-11-27 00:07:40 -05:00
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
|
2024-10-19 16:37:40 -04:00
|
|
|
export default async function SetupLayout({
|
2024-12-21 14:11:10 -05:00
|
|
|
children
|
2024-10-19 16:37:40 -04:00
|
|
|
}: {
|
|
|
|
children: React.ReactNode;
|
|
|
|
}) {
|
2024-11-26 20:30:52 -05:00
|
|
|
const getUser = cache(verifySession);
|
|
|
|
const user = await getUser();
|
|
|
|
|
|
|
|
if (!user) {
|
2024-11-28 00:11:13 -05:00
|
|
|
redirect("/?redirect=/setup");
|
2024-11-26 20:30:52 -05:00
|
|
|
}
|
|
|
|
|
2024-12-25 15:54:32 -05:00
|
|
|
if (
|
|
|
|
!(process.env.DISABLE_USER_CREATE_ORG === "false" || user.serverAdmin)
|
|
|
|
) {
|
|
|
|
redirect("/");
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="w-full max-w-2xl mx-auto p-3 md:mt-32">{children}</div>
|
|
|
|
);
|
2024-10-19 16:37:40 -04:00
|
|
|
}
|