Merge pull request #483 from shocknet/protected-route-middleware-check

Check method and path are defined in middleware
This commit is contained in:
Daniel Lugo 2021-10-10 22:15:01 -04:00 committed by GitHub
commit e066bfe939

View file

@ -356,7 +356,21 @@ module.exports = async (
}) })
app.use(async (req, res, next) => { app.use(async (req, res, next) => {
if (unprotectedRoutes[req.method][req.path]) { if (!req.method) {
logger.error(
'No req.method in unprotected routes middleware.',
'req.path:',
req.path
)
next()
} else if (!req.path) {
logger.error(
'No req.path in unprotected routes middleware.',
'req.method:',
req.method
)
next()
} else if (unprotectedRoutes[req.method][req.path]) {
next() next()
} else { } else {
try { try {