Skip to content

Commit

Permalink
Merge pull request #36 from TEDx-SJEC/restrict
Browse files Browse the repository at this point in the history
added restriction to register page
  • Loading branch information
joywin2003 authored Oct 7, 2024
2 parents 248df7b + c3a89f0 commit 3276ed2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
28 changes: 16 additions & 12 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
/** @type {import('next').NextConfig} */
const nextConfig = {

images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'tedx-sjec.github.io',
port: '',
pathname: '/**',
},
],
},

images: {
remotePatterns: [
{
protocol: "https",
hostname: "tedx-sjec.github.io",
port: "",
pathname: "/**",
},
{
protocol: "https",
hostname: "startup-template-sage.vercel.app",
port: "",
pathname: "/**",
},
],
},
};

export default nextConfig;
5 changes: 0 additions & 5 deletions src/components/navbar/nav-items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,5 @@ const NavItem = ({ href, textOne, textTwo }: NavItemProps) => {
);
};

NavItem.defaultProps = {
href: "#",
textOne: "ABOUT",
textTwo: "ABOUT",
};

export default NavItem;
7 changes: 6 additions & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ 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
export const config = {
matcher: ["/:path*", "/"],
matcher: ["/:path*", "/", "/admin/:path*", "/register/:path*"],
};

0 comments on commit 3276ed2

Please sign in to comment.