HTTP Routes now have an isAuthenticated middleware that returns a 401 error if the user is unauthenticated
This commit is contained in:
parent
ddfbb2aeed
commit
e45aab639f
1 changed files with 11 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue