Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add et strike middleware
  • Loading branch information
regalijan committed Feb 28, 2024
1 parent 5a8333f commit 90d0a6c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions functions/api/events-team/strikes/_middleware.ts
@@ -0,0 +1,18 @@
import { jsonError } from "../../../common.js";

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

if (!user) return jsonError("Not logged in", 401);

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

if (
context.request.method !== "GET" &&
![1 << 4, 1 << 12].find((p) => user.permissions & p)
)
return jsonError("Cannot manage strikes", 403);

return await context.next();
}

0 comments on commit 90d0a6c

Please sign in to comment.