Testing the Middleware
const globalResponseDto = require('../responses/globalResponseDto')
const isAuthenticated = (req, res, next) => {
if (!req.session.user) {
return res.status(401).json(
globalResponseDto({
status: 'error',
code: 401,
message:
'Access denied: you must be logged in to access this API endpoint.',
data: null,
errors: ['You must be logged in.']
})
)
}
next()
}
module.exports = isAuthenticatedThe Passing Test
The Passing Test
Last updated