Merge pull request #236 from shocknet/bug/gundb-http-auth-middleware

401 fix for unauthorized Gun users
This commit is contained in:
CapDog 2020-11-03 15:10:32 -06:00 committed by GitHub
commit 5dafed1a00

View file

@ -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)