"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    demoUserNotAllowed: function() {
        return demoUserNotAllowed;
    },
    demoUserNotAllowedInterceptor: function() {
        return demoUserNotAllowedInterceptor;
    }
});
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();
    };
});
const demoUserNotAllowedInterceptor = {
    before: [
        demoUserNotAllowed
    ]
};

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