Merge pull request #236 from shocknet/bug/gundb-http-auth-middleware
401 fix for unauthorized Gun users
This commit is contained in:
commit
5dafed1a00
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'
|
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()
|
next()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(err)
|
logger.error(err)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue