resolved error handling issue with requireAuth middleware

This commit is contained in:
Sheen Capadngan
2023-05-28 23:06:20 +08:00
parent b975115443
commit 8e972c704a
3 changed files with 61 additions and 57 deletions
-1
View File
@@ -166,7 +166,6 @@ const main = async () => {
);
});
// await createTestUserForDevelopment();
setUpHealthEndpoint(server);
server.on("close", async () => {
+4 -1
View File
@@ -45,7 +45,7 @@ const requireAuth = ({
// validate auth token against accepted auth modes [acceptedAuthModes]
// and return token type [authTokenType] and value [authTokenValue]
try {
const { authMode, authTokenValue } = validateAuthMode({
headers: req.headers,
acceptedAuthModes
@@ -94,6 +94,9 @@ const requireAuth = ({
}
return next();
} catch (err) {
return next(err);
}
}
}
+2
View File
@@ -24,6 +24,7 @@ import {
getMongoURL,
getSentryDSN
} from '../../config';
import { initializePassport } from '../auth';
/**
* Prepare Infisical upon startup. This includes tasks like:
@@ -48,6 +49,7 @@ export const setup = async () => {
// initializing the database connection
await DatabaseService.initDatabase(await getMongoURL());
await initializePassport();
/**
* NOTE: the order in this setup function is critical.