✨ 🚧 Add admin api and ui for timetable management
This commit is contained in:
@ -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({
|
||||
|
||||
Reference in New Issue
Block a user