"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "demoUserNotAllowed", {
    enumerable: true,
    get: function() {
        return demoUserNotAllowed;
    }
});
const _runtimeexceptions = require("../exceptions/runtime.exceptions");
const _awilixexpress = require("awilix-express");
const demoUserNotAllowed = (0, _awilixexpress.inject)((userService, configService, loggerFactory)=>{
    const logger = loggerFactory(demoUserNotAllowed.name);
    return async (req, res, next)=>{
        const isDemoMode = configService.isDemoMode();
        if (!isDemoMode) {
            next();
            return;
        }
        const demoUserId = await userService.getDemoUserId();
        if (req.user?.id === demoUserId) {
            logger.warn("Demo user attempted to access restricted resource", req.path);
            throw new _runtimeexceptions.ForbiddenError("Demo user attempted to access restricted resource");
        }
        next();
    };
});

//# sourceMappingURL=demo.middleware.js.map