Closed federicosan closed 5 years ago
Hi @federicosan ,
This is because in the authz plugin, we assume the the username is stored in req.user
and Casbin enforcer will read it. You can modify the following getUserName()
function to get the username string from anywhere you like.
Hi @hsluoyz, thank you for your reply. I am not that experienced in express but it seems the express-way to pass around data between middleware is to use req.locals, see it here -> https://expressjs.com/es/api.html#res.locals
@nodece
Hi @federicosan , we have a PR to solve this issue: https://github.com/node-casbin/express-authz/pull/6
Is it what you want?
@hsluoyz Sorry for the delay, yes that's it!
Nice. Close this issue now..
I don't understand this part
https://github.com/node-casbin/express-authz/blob/f26ab2fe2c218ef0f97b5fbaf2e74e5d465c114a/test/server.js#L21-L26
Are you just trying to get the logged in username, why saving it to
req.user
and notreq.locals.user
orreq.locals.currentUser
?