From 517e00aeb165c1553e3c282aa8773b4a8f40cb7d Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 19 Aug 2026 11:27:37 -0400 Subject: [PATCH] Fix admin auth gap from basePath stripping, add password reveal toggle Middleware compared request.nextUrl.pathname (basePath already stripped by Next.js) against paths still prefixed with /shop, so /shop/admin pages loaded without server-side auth protection. Co-Authored-By: Claude Opus 5 --- estore/src/app/admin/login/page.tsx | 19 +++++++++++++++++-- estore/src/middleware.ts | 4 ++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/estore/src/app/admin/login/page.tsx b/estore/src/app/admin/login/page.tsx index 6f16719..fa0db61 100644 --- a/estore/src/app/admin/login/page.tsx +++ b/estore/src/app/admin/login/page.tsx @@ -10,6 +10,7 @@ export default function AdminLoginPage() { const [password, setPassword] = useState('') const [error, setError] = useState('') const [loading, setLoading] = useState(false) + const [showPassword, setShowPassword] = useState(false) async function handleSubmit(e: React.FormEvent) { e.preventDefault() @@ -34,16 +35,30 @@ export default function AdminLoginPage() {

Admin Login

-
+
setPassword(e.target.value)} autoFocus required /> +
{error &&

{error}

} diff --git a/estore/src/middleware.ts b/estore/src/middleware.ts index 50f869a..f71e811 100644 --- a/estore/src/middleware.ts +++ b/estore/src/middleware.ts @@ -28,11 +28,11 @@ async function deriveSessionToken(password: string): Promise { export async function middleware(request: NextRequest) { const { pathname } = request.nextUrl - if (pathname === '/shop/admin/login' || pathname === '/api/admin/login') { + if (pathname === '/admin/login' || pathname === '/api/admin/login') { return NextResponse.next() } - if (pathname.startsWith('/shop/admin') || pathname.startsWith('/api/admin')) { + if (pathname.startsWith('/admin') || pathname.startsWith('/api/admin')) { const token = request.cookies.get(COOKIE)?.value const password = process.env.ADMIN_PASSWORD