Add et strike middleware
This commit is contained in:
parent
5a8333feed
commit
90d0a6c729
18
functions/api/events-team/strikes/_middleware.ts
Normal file
18
functions/api/events-team/strikes/_middleware.ts
Normal file
@ -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();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user