Sindbad~EG File Manager

Current Path : /home/infinitibizsol/irfarms.infinitibizsol.com/middleware/
Upload File :
Current File : /home/infinitibizsol/irfarms.infinitibizsol.com/middleware/allowedOnlyTo.js

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _apiError = _interopRequireDefault(require("../utils/apiError"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var allowedOnlyTo = function allowedOnlyTo() {
  for (var _len = arguments.length, roles = new Array(_len), _key = 0; _key < _len; _key++) {
    roles[_key] = arguments[_key];
  }
  return function (req, res, next) {
    var role = req.user.role;

    // Check if the user role is permitted
    if (!roles.includes(role)) {
      throw new _apiError["default"]("Access denied. Only ".concat(roles.join(" or "), " can access this route."));
    }
    next();
  };
};
var _default = exports["default"] = allowedOnlyTo;

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists