Added bannend check
This commit is contained in:
@@ -6,8 +6,6 @@ import { getServerSession } from "./api/auth/[...nextauth]/auth";
|
||||
import { Toaster } from "react-hot-toast";
|
||||
import { QueryProvider } from "_components/QueryProvider";
|
||||
import { Error as ErrorComp } from "_components/Error";
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
import { CustomErrorBoundary } from "_components/ErrorBoundary";
|
||||
|
||||
const geistSans = localFont({
|
||||
src: "./fonts/GeistVF.woff",
|
||||
@@ -50,7 +48,12 @@ export default async function RootLayout({
|
||||
reverseOrder={false}
|
||||
/>
|
||||
<QueryProvider>
|
||||
<NextAuthSessionProvider session={session}>{children}</NextAuthSessionProvider>
|
||||
<NextAuthSessionProvider session={session}>
|
||||
{session?.user.isBanned && (
|
||||
<ErrorComp title="You are banned from using this service" statusCode={403} />
|
||||
)}
|
||||
{!session?.user.isBanned && children}
|
||||
</NextAuthSessionProvider>
|
||||
</QueryProvider>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -4,6 +4,7 @@ import { HorizontalNav, VerticalNav } from "../_components/Nav";
|
||||
import { Toaster } from "react-hot-toast";
|
||||
import { redirect } from "next/navigation";
|
||||
import { getServerSession } from "../api/auth/[...nextauth]/auth";
|
||||
import { Error } from "_components/Error";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "VAR: Hub",
|
||||
@@ -17,6 +18,9 @@ export default async function RootLayout({
|
||||
}>) {
|
||||
const session = await getServerSession();
|
||||
|
||||
if (session?.user.isBanned)
|
||||
return <Error title="You are banned from using this service" statusCode={403} />;
|
||||
|
||||
if (!session) redirect(`/login`);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user