The coconut token value is a string, not an object
This commit is contained in:
parent
a521baf277
commit
db2946c68e
@ -10,15 +10,14 @@ export async function onRequestPost(context: RequestContext) {
|
|||||||
return jsonError("Invalid report id or token", 400);
|
return jsonError("Invalid report id or token", 400);
|
||||||
|
|
||||||
const id = attachment.replace(/\.mp4$/, "");
|
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}`,
|
`coconutjob_${id}`,
|
||||||
{ type: "json" },
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!coconutData)
|
if (!coconutToken)
|
||||||
return jsonError("Request is stale or otherwise invalid", 400);
|
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}`);
|
await context.env.DATA.delete(`coconutjob_${id}`);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user