Skip to content

Commit

Permalink
Add check in auth middleware (#2376)
Browse files Browse the repository at this point in the history
* Add check in auth middleware

* lint
  • Loading branch information
dmanjunath committed Jan 24, 2022
1 parent 1bedc6c commit 1087b76
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions creator-node/src/middlewares.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const models = require('./models')
const utils = require('./utils')
const { hasEnoughStorageSpace } = require('./fileManager')
const { getMonitors, MONITORS } = require('./monitors/monitors')
const BlacklistManager = require('./blacklistManager')

/**
* Ensure valid cnodeUser and session exist for provided session token
Expand Down Expand Up @@ -65,6 +66,15 @@ async function authMiddleware(req, res, next) {
}
}

const userBlacklisted = await BlacklistManager.userIdIsInBlacklist(userId)
if (userBlacklisted) {
return sendResponse(
req,
res,
errorResponseUnauthorized('User not allowed to make changes on node')
)
}

// Attach session object to request
req.session = {
cnodeUser: cnodeUser,
Expand Down

0 comments on commit 1087b76

Please sign in to comment.