🚧 Add admin api and ui for timetable management

This commit is contained in:
2023-06-20 23:10:52 +02:00
parent 0e2cc70a6b
commit 0ae553cca8
10 changed files with 307 additions and 5 deletions

View File

@ -32,6 +32,18 @@ export async function hasPermission(sessionToken, permission, forValue) {
return hasPermission;
}
export async function checkAdmin(req, res, next) {
if (!(await hasPermission(req.locals.session, "admin"))) {
res.status(401).send({
success: false,
error: "admin_only",
message: "You need to be admin to do this!",
});
return;
}
next();
}
export async function applyKey(sessionToken, key) {
if (!key) return false;
const foundKey = await prisma.key.findUnique({