init repo
This commit is contained in:
23
src/app/blog-posts/layout.tsx
Normal file
23
src/app/blog-posts/layout.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import authOptions from "@app/api/auth/[...nextauth]/options";
|
||||
import { Header } from "@components/header";
|
||||
import { ThemedLayout } from "@refinedev/mui";
|
||||
import { getServerSession } from "next-auth/next";
|
||||
import { redirect } from "next/navigation";
|
||||
import React from "react";
|
||||
|
||||
export default async function Layout({ children }: React.PropsWithChildren) {
|
||||
const data = await getData();
|
||||
|
||||
if (!data.session?.user) {
|
||||
return redirect("/login");
|
||||
}
|
||||
|
||||
return <ThemedLayout Header={Header}>{children}</ThemedLayout>;
|
||||
}
|
||||
|
||||
async function getData() {
|
||||
const session = await getServerSession(authOptions);
|
||||
return {
|
||||
session,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user