From 574902db4ad5f33ba8ec9cef6fb48e70f1c9d80a Mon Sep 17 00:00:00 2001 From: Erik Taubeneck Date: Fri, 7 Jun 2024 22:51:04 -0700 Subject: [PATCH] [failsafe] block demo user outside development if added to prod database by mistake --- server/middleware.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/middleware.ts b/server/middleware.ts index 48567d0..f5d1875 100644 --- a/server/middleware.ts +++ b/server/middleware.ts @@ -59,7 +59,6 @@ export async function middleware(request: NextRequest) { email: 'demo@draft.test', password: 'password', }) - console.log(data); return response } const { @@ -67,7 +66,7 @@ export async function middleware(request: NextRequest) { } = await supabase.auth.getUser(); const allowedPathsRegex = new RegExp(`^(/|/login|/auth/callback|/docs/.+)$`); - if (!user && !allowedPathsRegex.test(request.nextUrl.pathname)) { + if ((!user || user.email === 'demo@draft.test') && !allowedPathsRegex.test(request.nextUrl.pathname)) { const url = request.nextUrl.clone(); url.pathname = `/404`; return NextResponse.rewrite(url);