From 2a6bd21029c9f4ab77bc7028b3b237f5ea5d0c9c Mon Sep 17 00:00:00 2001 From: Shlee Date: Sun, 16 Aug 2026 22:10:07 +0930 Subject: [PATCH] Update verifyApiKeyAccess.ts --- server/middlewares/verifyApiKeyAccess.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/server/middlewares/verifyApiKeyAccess.ts b/server/middlewares/verifyApiKeyAccess.ts index ea1bdac18..47dac03f0 100644 --- a/server/middlewares/verifyApiKeyAccess.ts +++ b/server/middlewares/verifyApiKeyAccess.ts @@ -70,13 +70,8 @@ export async function verifyApiKeyAccess( ); } - if (!apiKeyOrg.orgId) { - return next( - createHttpError( - HttpCode.INTERNAL_SERVER_ERROR, - `API key with ID ${apiKeyId} does not have an organization ID` - ) - ); + if (!apiKey.apiKeyOrg?.orgId) { + return next(createHttpError(HttpCode.INTERNAL_SERVER_ERROR, `API key with ID ${apiKeyId} does not have an organization ID`)); } if (!req.userOrg) { @@ -86,7 +81,7 @@ export async function verifyApiKeyAccess( .where( and( eq(userOrgs.userId, userId), - eq(userOrgs.orgId, apiKeyOrg.orgId) + eq(userOrgs.orgId, apiKey.apiKeyOrg.orgId) ) ) .limit(1);