From a8c5ef25f7e35d8ab37e39e26fe3c7f1b95c08b5 Mon Sep 17 00:00:00 2001 From: Theis Gaedigk Date: Tue, 11 Nov 2025 21:01:09 +0100 Subject: [PATCH] fixed 403 bug --- backendV2/services/authentication.js | 9 +++------ backendV2/services/database.js | 8 ++++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/backendV2/services/authentication.js b/backendV2/services/authentication.js index 1940b81..4fadd38 100644 --- a/backendV2/services/authentication.js +++ b/backendV2/services/authentication.js @@ -62,11 +62,8 @@ export async function authenticate(req, res, next) { } } else if (apiKey) { try { - await verifyAPIKey(apiKey).then((result) => { - if (result.valid) { - return next(); - } - }); + await verifyAPIKey(apiKey); + return next(); } catch { return res.status(403).json({ message: "API Key invalid" }); // fix: don't chain after sendStatus } @@ -79,7 +76,7 @@ async function verifyAPIKey(apiKey) { const result = await verifyAPIKeyDB(apiKey); if (result.valid) { - return { valid: true }; + return; } else { throw new Error("Invalid API Key"); } diff --git a/backendV2/services/database.js b/backendV2/services/database.js index 09af3bd..6a09279 100644 --- a/backendV2/services/database.js +++ b/backendV2/services/database.js @@ -4,10 +4,10 @@ dotenv.config(); const pool = mysql .createPool({ - host: process.env.DB_HOST_2, - user: process.env.DB_USER_2, - password: process.env.DB_PASSWORD_2, - database: process.env.DB_NAME_2, + host: process.env.DB_HOST, + user: process.env.DB_USER, + password: process.env.DB_PASSWORD, + database: process.env.DB_NAME, }) .promise();