From f1f4dc097e8d538a70592050dddf515ea3da4540 Mon Sep 17 00:00:00 2001 From: AI Assistant Date: Wed, 25 Mar 2026 00:49:44 +0200 Subject: [PATCH] fix(portal): full-screen overlay + redirect portal-only users Portal layout: removed conflicting (portal)/layout.tsx that had duplicate html/body tags. Portal page now uses fixed overlay (z-[100]) that covers the entire screen including sidebar. Middleware: portal-only users (dan.tiurbe) are automatically redirected from any non-portal route to /portal. They can still access /api/ and /auth/ routes normally. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/app/(portal)/layout.tsx | 29 ----------------------------- src/app/(portal)/portal/page.tsx | 2 +- src/middleware.ts | 14 +++++++++++++- 3 files changed, 14 insertions(+), 31 deletions(-) delete mode 100644 src/app/(portal)/layout.tsx diff --git a/src/app/(portal)/layout.tsx b/src/app/(portal)/layout.tsx deleted file mode 100644 index 4965394..0000000 --- a/src/app/(portal)/layout.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import type { Metadata } from "next"; -import { Inter } from "next/font/google"; -import "../globals.css"; -import { Providers } from "../providers"; - -const inter = Inter({ subsets: ["latin", "latin-ext"] }); - -export const metadata: Metadata = { - title: "Portal Tiurbe — ArchiTools", - description: "Portal extern — documente RGI si harta cadastrala", -}; - -export default function PortalLayout({ - children, -}: { - children: React.ReactNode; -}) { - return ( - - - -
- {children} -
-
- - - ); -} diff --git a/src/app/(portal)/portal/page.tsx b/src/app/(portal)/portal/page.tsx index d5aee9e..bd1b91d 100644 --- a/src/app/(portal)/portal/page.tsx +++ b/src/app/(portal)/portal/page.tsx @@ -1477,7 +1477,7 @@ function HartaContent() { export default function PortalPage() { return ( -
+
{/* Header */}
diff --git a/src/middleware.ts b/src/middleware.ts index 0157535..5605d0f 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -12,8 +12,20 @@ export async function middleware(request: NextRequest) { secret: process.env.NEXTAUTH_SECRET, }); - // Authenticated — allow through + // Authenticated — check for portal-only users if (token) { + const { pathname } = request.nextUrl; + // Portal-only users: redirect to /portal when accessing main app + const portalUsers = ["dan.tiurbe", "tiurbe"]; + const tokenEmail = String(token.email ?? "").toLowerCase(); + const tokenName = String(token.name ?? "").toLowerCase(); + const isPortalUser = portalUsers.some( + (u) => tokenEmail.includes(u) || tokenName.includes(u), + ); + if (isPortalUser && !pathname.startsWith("/portal") && !pathname.startsWith("/api/") && !pathname.startsWith("/auth/")) { + const baseUrl = process.env.NEXTAUTH_URL || "https://tools.beletage.ro"; + return NextResponse.redirect(new URL("/portal", baseUrl)); + } return NextResponse.next(); }