better typing, authorization middleware, test for creating apikeys
This commit is contained in:
8
server-node/src/auth/checkAuthorizedMiddleware.ts
Normal file
8
server-node/src/auth/checkAuthorizedMiddleware.ts
Normal 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."});
|
||||
}
|
||||
Reference in New Issue
Block a user