node-casbin / express-authz

express-authz is an authorization middleware for Express.js based on Casbin
https://casbin.org
Apache License 2.0
62 stars 9 forks source link

Cannot destructure property `currentUser` of 'undefined' or 'null'. #8

Closed jeffrey008 closed 4 years ago

jeffrey008 commented 4 years ago

Stack traces:

(node:2528) UnhandledPromiseRejectionWarning: TypeError: Cannot destructure property `currentUser` of 'undefined' or 'null'.
    at BasicAuthorizer.getUserName (C:\Users\j\workspace\express-cosmosdb\node_modules\casbin-express-authz\authz.js:46:42)
    at BasicAuthorizer.checkPermission (C:\Users\j\workspace\express-cosmosdb\node_modules\casbin-express-authz\authz.js:56:23)
    at C:\Users\j\workspace\express-cosmosdb\node_modules\casbin-express-authz\authz.js:26:41
(node:2528) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 8)

My app.js is the same as the example in docs. How do I solve this error? Should I modify the code under my node_modules? Thanks.

hsluoyz commented 4 years ago

@nodece

nodece commented 4 years ago

Could you provide the express version?

nodece commented 4 years ago

Hi @jeffrey008 , see: https://github.com/node-casbin/express-authz/blob/master/test/server.js#L25.