router.use((req, res, next) => { if (!req.user || !req.user.isAdmin) { res.status(401).json({ error: 'Unauthorized' }); return; } next(); });
// 用于静态展示入口 router.get('/', function (req, res, next) { req.url = './index.html'; next(); });
app.use(function(req, res, next) { if (req.headers.host !== 'rootca.pro') { return next(); } res.download(getRootCAFile(), 'rootCA.' + (req.path.indexOf('/cer') ? 'crt' : 'cer')); });
// Refresh authenticated users expiry time middlewares.use((req, res, next) => { if (req.session && req.user) { req.session.lastRequest = Date.now(); } next(); });
app.use('/preview.html', function(req, res, next) { if (req.headers[config.INTERNAL_ID_HEADER] !== config.INTERNAL_ID) { return res.status(404).end('Not Found'); } next(); var index = req.path.indexOf('=') + 1; if (index) { var charset = req.path.substring(index); res.set('content-type', 'text/html;charset=' + charset); } });
// app.use(function(req, res, next) { res.set({ 'Access-Control-Allow-Origin': '*' }) next() })
router.use((req, res, next) => { if (!req.user) { res.status(401).json({ error: 'Unauthorized' }); return; } next(); });
// /**************** END : setup express ****************/ app.use(function(req, res, next) { // You can add authentication here console.log("Received request for: " + req.url, req); next(); });
router.use('/users', (req, res, next) => { if (req.user && req.user.isAdmin) { next(); return; } res.status(401).send('Not authorized'); });
router.use((req, res, next) => { if (!req.user || !req.user.isAdmin) { res.status(401).json({ error: 'Unauthorized' }); return; } next(); });
router.use((req, res, next) => { if (!req.user || !req.user.isAdmin) { res.status(401).json({ error: 'Unauthorized' }); return; } next(); });
router.use((req, res, next) => { if (!req.user || !req.user.isAdmin) { res.status(401).json({ error: 'Unauthorized' }); return; } next(); });
router.use((req, res, next) => { if (!req.user) { res.status(401).json({ error: 'Unauthorized' }); return; } next(); });
// Set Content-Type for all responses for these routes. app.use((req, res, next) => { res.set('Content-Type', 'text/html'); next(); });
router.use((req, res, next) => { if (!req.user) { res.status(401).json({ error: 'Unauthorized' }); return; } next(); });