Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Create direct game bans middleware
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 32387f9 commit 4687540
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions functions/api/game-bans/_middleware.ts
@@ -0,0 +1,21 @@
export async function onRequest(context: RequestContext) {
const { current_user: currentUser } = context.data;

if (!currentUser)
return new Response('{"error":Not logged in"}', {
headers: {
"content-type": "application/json",
},
status: 401,
});

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 4687540

Please sign in to comment.