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