Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
The coconut token value is a string, not an object
  • Loading branch information
regalijan committed Mar 26, 2024
1 parent a521baf commit db2946c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions functions/api/coconut.ts
Expand Up @@ -10,15 +10,14 @@ export async function onRequestPost(context: RequestContext) {
return jsonError("Invalid report id or token", 400);

const id = attachment.replace(/\.mp4$/, "");
const coconutData: { token: string } | null = await context.env.DATA.get(
const coconutToken: string | null = await context.env.DATA.get(
`coconutjob_${id}`,
{ type: "json" },
);

if (!coconutData)
if (!coconutToken)
return jsonError("Request is stale or otherwise invalid", 400);

if (coconutData.token !== token) return jsonError("Forbidden", 403);
if (coconutToken !== token) return jsonError("Forbidden", 403);

await context.env.DATA.delete(`coconutjob_${id}`);

Expand Down

0 comments on commit db2946c

Please sign in to comment.