Merge pull request #483 from shocknet/protected-route-middleware-check
Check method and path are defined in middleware
This commit is contained in:
commit
e066bfe939
1 changed files with 15 additions and 1 deletions
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue