mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-10 14:28:35 +00:00
resolved error handling issue with requireAuth middleware
This commit is contained in:
@@ -166,7 +166,6 @@ const main = async () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// await createTestUserForDevelopment();
|
|
||||||
setUpHealthEndpoint(server);
|
setUpHealthEndpoint(server);
|
||||||
|
|
||||||
server.on("close", async () => {
|
server.on("close", async () => {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ const requireAuth = ({
|
|||||||
|
|
||||||
// validate auth token against accepted auth modes [acceptedAuthModes]
|
// validate auth token against accepted auth modes [acceptedAuthModes]
|
||||||
// and return token type [authTokenType] and value [authTokenValue]
|
// and return token type [authTokenType] and value [authTokenValue]
|
||||||
|
try {
|
||||||
const { authMode, authTokenValue } = validateAuthMode({
|
const { authMode, authTokenValue } = validateAuthMode({
|
||||||
headers: req.headers,
|
headers: req.headers,
|
||||||
acceptedAuthModes
|
acceptedAuthModes
|
||||||
@@ -94,6 +94,9 @@ const requireAuth = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return next();
|
return next();
|
||||||
|
} catch (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
getMongoURL,
|
getMongoURL,
|
||||||
getSentryDSN
|
getSentryDSN
|
||||||
} from '../../config';
|
} from '../../config';
|
||||||
|
import { initializePassport } from '../auth';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare Infisical upon startup. This includes tasks like:
|
* Prepare Infisical upon startup. This includes tasks like:
|
||||||
@@ -48,6 +49,7 @@ export const setup = async () => {
|
|||||||
|
|
||||||
// initializing the database connection
|
// initializing the database connection
|
||||||
await DatabaseService.initDatabase(await getMongoURL());
|
await DatabaseService.initDatabase(await getMongoURL());
|
||||||
|
await initializePassport();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NOTE: the order in this setup function is critical.
|
* NOTE: the order in this setup function is critical.
|
||||||
|
|||||||
Reference in New Issue
Block a user