Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Create point route middleware
  • Loading branch information
regalijan committed Feb 27, 2024
1 parent dd24dfe commit 3451f08
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions functions/api/events-team/points/_middleware.ts
@@ -0,0 +1,12 @@
import { jsonError } from "../../../common.js";

export async function onRequest(context: RequestContext) {
const { current_user: user } = context.data;

if (!user) return jsonError("You are not logged in", 401);

if (![1 << 3, 1 << 4, 1 << 2].find((p) => user.permissions & p))
return jsonError("Not part of Events Team", 403);

return await context.next();
}

0 comments on commit 3451f08

Please sign in to comment.