-
Notifications
You must be signed in to change notification settings - Fork 117
context.params.user is empty object #635
Comments
What does the encoded JWT you are sending look like? I'm suspecting it does not have a |
Here's genetated token: Seems there's no userId. Do you have any thoughts why it can be so ? |
The problem is that I don't call authentication service directly, but do smth. like:
because I need to avoid passing "strategy", just username and password and use another url. |
That information would've been quite useful at the beginning ;) Only external calls are expected to pass authentication information like that (on the server you can just create any token you want) so you'll have to pass params.provider to make it look like an external call: app.post('/users/authenticate', function (req, res, next) {
app.service('/authentication').create({
strategy: 'local',
email: req.body.email,
password: req.body.password
}, { provider: 'express' }).then(token => {
res.send(token);
});
}); |
Using auth.hooks.authenticate(['jwt'])
Trying to get current user from hook.
There is context.params.user but it's empty object.
Changing "entity" option works, still context.params['entity'] is empty.
Am i doing something wrong ?
Steps to reproduce
Use auth.hooks.authenticate(['jwt']) hook
Use own hook afterwards and try getting context.params.user
Expected behavior
context.params.user populated with user object (or at least userId)
Actual behavior
context.params.user is empty object
Module versions (especially the part that's not working):
"@feathersjs/authentication": "^2.1.1",
"@feathersjs/authentication-jwt": "^1.0.2",
"@feathersjs/authentication-local": "^1.0.4",
The text was updated successfully, but these errors were encountered: