From 1af1c8188875dadc8b984f69d7b600ae22aa07cb Mon Sep 17 00:00:00 2001 From: Joywin Bennis <107112207+joywin2003@users.noreply.github.com> Date: Wed, 20 Nov 2024 00:18:48 +0530 Subject: [PATCH] No registration allowed for non-admins --- src/components/common/cta-section-2.tsx | 2 +- src/components/widget/header.tsx | 2 +- src/components/widget/hero.tsx | 2 +- src/middleware.ts | 6 ++++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/common/cta-section-2.tsx b/src/components/common/cta-section-2.tsx index 3d02b2e..e118087 100644 --- a/src/components/common/cta-section-2.tsx +++ b/src/components/common/cta-section-2.tsx @@ -82,7 +82,7 @@ export default function FullScreenCTA() { size="lg" className="bg-red-600 hover:bg-red-700 text-white py-6 px-4 text-xl transition-all duration-300 transform hover:scale-105 mt-8" > - Register Now + Registrations Open Soon {/*

diff --git a/src/components/widget/header.tsx b/src/components/widget/header.tsx index 6982d8c..5726a55 100644 --- a/src/components/widget/header.tsx +++ b/src/components/widget/header.tsx @@ -189,7 +189,7 @@ const Nav = () => { size="lg" className="bg-red-600 hover:bg-red-700 text-white py-4 " > - Register Now + Registrations Open Soon {/* */} diff --git a/src/components/widget/hero.tsx b/src/components/widget/hero.tsx index d5cd6a3..7feb325 100644 --- a/src/components/widget/hero.tsx +++ b/src/components/widget/hero.tsx @@ -129,7 +129,7 @@ export default function HeroHighlight() { size="lg" className="bg-red-600 hover:bg-red-700 text-white py-2 transition-all duration-300 transform hover:scale-105" > - Register Now + Registrations Open Soon diff --git a/src/middleware.ts b/src/middleware.ts index 20f37ed..f7d4152 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -13,6 +13,12 @@ export async function middleware(request: NextRequest) { return NextResponse.redirect(new URL("/", request.url)); } } + if (url.pathname.startsWith("/register")) { + if (token?.role !== "ADMIN") { + return NextResponse.redirect(new URL("/", request.url)); + } + } + } // See "Matching Paths" below to learn more