simplify auth check

main
cogentapps 2023-07-04 20:12:32 +00:00
parent 6ed206ccc8
commit 8e36104637
1 changed files with 1 additions and 3 deletions

View File

@ -6,14 +6,12 @@ export default class SessionRequestHandler extends RequestHandler {
async handler(req: express.Request, res: express.Response) {
const request = req as any;
const authenticated = !!(request.oidc?.user?.sub || request.session?.passport?.user?.id);
const availableServiceNames = Object.keys(config.services || {})
.filter(key => {
const serviceConfig = (config.services as any)?.[key];
const apiKey = serviceConfig?.apiKey;
const loginRequired = serviceConfig?.loginRequired ?? true;
return apiKey && (!loginRequired || authenticated);
return apiKey && (!loginRequired || this.userID);
});
if (request.oidc) {