/* import { NextFunction, Request, Response } from "express";
import { AppDataSource } from "../data-source.js";
import { UserEntity } from "../entities/UserEntity.js";

// @todo we'll need some other means to determin the user corresponding to the token here as it seems...
export const authorization = (roles: string[]) => {
  return async (req: Request, res: Response, next: NextFunction) => {
    const userRepo = AppDataSource.getRepository(UserEntity);
    const currentUser = req.currentUser;
    if(!currentUser){
      return res.status(403).json({ message: "Forbidden - currentUser is missing" });
    }
    const userId = currentUser.id 
    const user = await userRepo.findOne({
      where: { id: req[" currentUser"].id },
    });
    console.log(user);
    if (!roles.includes(user.role)) {
      return res.status(403).json({ message: "Forbidden" });
    }
    next();
  }; 
};*/