From 020d6a7e763caa1ff03b83c0e7bef3b2b37073df Mon Sep 17 00:00:00 2001 From: mbaharip <62494292+mbahArip@users.noreply.github.com> Date: Thu, 25 May 2023 23:17:39 +0700 Subject: [PATCH] Replace cookie name with the one in constant --- src/app/(api)/api/validate/[...path]/route.ts | 8 +++++--- src/app/(api)/api/validate/route.ts | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/app/(api)/api/validate/[...path]/route.ts b/src/app/(api)/api/validate/[...path]/route.ts index 744eb0a..62a7a94 100644 --- a/src/app/(api)/api/validate/[...path]/route.ts +++ b/src/app/(api)/api/validate/[...path]/route.ts @@ -146,7 +146,9 @@ export async function GET( ); const nearestProtectedFolder = protectedFolder[protectedFolder.length - 1] ?? null; - const masterKey = request.headers.get("x-gdrive-key"); + const masterKey = request.headers.get( + Constant.cookieMaster, + ); const validMasterKey = passwordHash.verify( masterKey || "", apiConfig.masterKey, @@ -166,7 +168,7 @@ export async function GET( ); const userPassword = cookies().get( - `next-gdrive-password`, + Constant.cookiePassword, )?.value; if (!userPassword) { throw new ExtendedError( @@ -212,7 +214,7 @@ export async function GET( !validMasterKey ) { const userPassword = cookies().get( - `next-gdrive-password`, + Constant.cookiePassword, )?.value; if (!userPassword) { throw new ExtendedError( diff --git a/src/app/(api)/api/validate/route.ts b/src/app/(api)/api/validate/route.ts index f6f4b59..5a40ff8 100644 --- a/src/app/(api)/api/validate/route.ts +++ b/src/app/(api)/api/validate/route.ts @@ -16,7 +16,9 @@ export async function GET(request: NextRequest) { const _start = Date.now(); try { - const masterKey = request.headers.get("x-gdrive-key"); + const masterKey = request.headers.get( + Constant.cookieMaster, + ); const validMasterKey = passwordHash.verify( masterKey || "", apiConfig.masterKey, @@ -24,7 +26,7 @@ export async function GET(request: NextRequest) { if (siteConfig.privateIndex && !validMasterKey) { const userPassword = cookies().get( - `next-gdrive-password`, + Constant.cookiePassword, )?.value; if (!userPassword) { throw new ExtendedError(