HTTP Routes now have an isAuthenticated middleware that returns a 401 error if the user is unauthenticated

This commit is contained in:
emad-salah 2020-10-30 15:28:10 +01:00
parent ddfbb2aeed
commit e45aab639f

View file

@ -416,6 +416,17 @@ module.exports = async (
errorMessage: 'Please create a wallet before using the API'
})
}
if (req.path.includes('/api/gun')) {
const authenticated = GunDB.isAuthenticated()
if (!authenticated) {
return res.status(401).json({
field: 'gun',
errorMessage: 'Please login in order to perform this action'
})
}
}
next()
} catch (err) {
logger.error(err)