Skip to content
Permalink
91a2f2ea5c
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
1 contributor

Users who have contributed to this file

22 lines (17 sloc) 577 Bytes
import { jsonError } from "../../common.js";
export async function onRequest(context: RequestContext) {
if (!context.data.current_user)
return jsonError("You are not logged in", 401);
const { permissions } = context.data.current_user;
const departments = {
DM: 1 << 2,
ET: 1 << 3,
FM: 1 << 10,
WM: 1 << 9,
};
const userDepartments = [];
for (const [dept, permission] of Object.entries(departments))
if (permissions & permission) userDepartments.push(dept);
context.data.departments = userDepartments;
return await context.next();
}