Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move upload permissions check to middleware
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 95367be commit 95d0686
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions functions/api/uploads/_middleware.ts
@@ -0,0 +1,13 @@
export async function onRequest(context: RequestContext) {
const { current_user: currentUser } = context.data;

if (!(currentUser?.permissions & (1 << 5)))
return new Response('{"error":"Forbidden"}', {
headers: {
"content-type": "application/json",
},
status: 403,
});

return await context.next();
}

0 comments on commit 95d0686

Please sign in to comment.