From 9f3f0a289746f30bc13bcf4bdd4888a39489cd59 Mon Sep 17 00:00:00 2001 From: Jon Breen Date: Thu, 9 May 2024 13:27:23 +0100 Subject: [PATCH] Null check on member before accessing --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 67e727a..edb07ca 100644 --- a/src/index.ts +++ b/src/index.ts @@ -243,7 +243,7 @@ app.get("/submit", auth0Middleware, async (c) => { const prisma = new PrismaClient({ adapter }); const auth0Payload: Auth0JwtPayload = c.var.auth0('payload'); - if (auth0Payload.permissions.includes('submit')) { + if (auth0Payload.permissions && auth0Payload.permissions.includes('submit')) { try { const submissionIds = await prisma.submissions.findMany({ where: { @@ -285,7 +285,7 @@ app.post("/submit", auth0Middleware, async (c) => { c.header("Access-Control-Allow-Origin", getOrigin(c.req.header("Origin"))); c.header("Access-Control-Allow-Methods", "POST,GET,OPTIONS"); - if (auth0Payload.permissions.includes('submit')) { + if (auth0Payload.permissions && auth0Payload.permissions.includes('submit')) { let originRequest = new Request(c.req.raw); const resp = await fetch(c.env.secureSubmitEndpoint, originRequest); if (resp.status == 200) {