Cannot change `requestProperty` object.
See original GitHub issueCannot seem to change the requestProperty of my user object to payload. Double checked req.payload and its working fine without the guard.
Here’s my express-JWT config:
let auth = {
required: jwt({
secret: secret,
userProperty: 'payload',
getToken: getTokenFromHeader
})
}
signing jwt
return jwt.sign({
id: this._id,
username: this.username,
exp: parseInt(exp.getTime() / 1000),
permissions: ['r','w']
}, secret);
Set using let guard = require('express-jwt-permissions')({requestProperty: 'payload'});
Accessing it using guard.check('r') throws 'user object payload was not found. Check your configuration.'
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Modify the URL of a new Request Object in ES6 - Stack Overflow
You can copy all the properties from the old request into a new one with a new url like so: const init =...
Read more >TypeError: can't define property "x": "obj" is not extensible
To fix this error, you will either need to remove the call to Object.preventExtensions() entirely, or move it to a position so that...
Read more >Modify request objects within middleware function #31188
One thing I've been unable to figure out is modifying request objects within a middleware. Is this currently possible?
Read more >Change Preprocessors - FileNet P8 - IBM
The source object in a create, update, or delete server request is passed to a change preprocessor handler. The source object includes a...
Read more >Re: Cannot change object of property - HubSpot Community
Hi , The object of a property cannot be changed after its creation. You would have to create a new one. Properties that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Glad you found the problem. 👍
I’ve found the cause of the problem. Given my code:
Calling
guard.check()first before an express-jwt rule results to not passing the request object properly.router.get('/foo', guard.check('root'), auth.required, function (req, res, next) {...}is fixed withrouter.get('/foo', auth.required, guard.check('root'),function (req, res, next) {...}Overlooked this simple mistake. Thanks for the quick response!