better typing, authorization middleware, test for creating apikeys

This commit is contained in:
Felix Kaspar
2024-05-30 03:19:47 +02:00
parent 187b7b3e78
commit 28862d70ca
6 changed files with 31 additions and 13 deletions

View File

@@ -0,0 +1,8 @@
import { Request, Response, NextFunction } from "express";
export function checkAuthorized(req: Request, res: Response, next: NextFunction) {
if(import.meta.env.VITE_AUTH_ENABLED === "False" || req.user) {
return next();
}
return res.status(403).json({"Error": "Authentication failed."});
}