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();
}