Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-02-01 02:28:31 +00:00
parent 7b0ca40c4f
commit 73025c84c5
10 changed files with 413 additions and 87 deletions

View File

@@ -21,3 +21,13 @@ export async function requireAuth(req, res, next) {
return res.status(401).json({ error: "Ongeldige of verlopen token." });
}
}
export function requireAdmin(req, res, next) {
if (!req.user) {
return res.status(401).json({ error: "Inloggen vereist." });
}
if (!req.user.isAdmin) {
return res.status(403).json({ error: "Administratorrechten vereist." });
}
next();
}