Skip to content

Commit

Permalink
simplify auth check
Browse files Browse the repository at this point in the history
  • Loading branch information
cogentapps committed Jul 4, 2023
1 parent 6ed206c commit 8e36104
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions server/src/endpoints/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8e36104

Please sign in to comment.