Closed ducnvhn closed 6 years ago
In order to reliably have params.user
set all service methods need the authenticate hook - usually by JWT via authenticate('jwt')
.
thanks @daffl. I will gibe it a try.
hi @daffl I have added:
import auth from 'feathers-authentication';
.
.
const postHook = {
before: {
create: [auth.hooks.authenticate(['jwt', 'local']), readHooksParams , associateCurrentUser({ idField: '_id', as: 'user' }), ....]
},
.
.
.
.
};
This hook run and parse correct jwt token on desktop browsers. How ever, some time it does not run on Chrome / Android.
Any advise?
I have never had issues in Chrome for Android but some browsers do not have a proper localStorage (e.g. in incognito mode). Using an alternative storage is documented in https://github.com/feathersjs/authentication/issues/135
Steps to reproduce
I've search some issues here, nothing relevant. On Desktop browswer, the associateWithCurrentUser works just fine, but on mobile browswer( Android /Chrome/ FF) , authentication hook not seem to work.
Expected behavior
associateWithCurrentUser and authentication header should be available at hook.params
Actual behavior
cannot use feathers-authentication-hooks with mobile browser client.
System configuration
Tell us about the applicable parts of your setup. I have a Feathers app setup behind a nginx reserve proxy server like this: Client -> Nginx -> Express (feathers) -> API (feathers). Client make a feathers service request and I am using
feathers-authentication-hooks
toassociateCurrentUser
to create a data field. client call service as normalapp.service('posts').create(data);
Module versions (especially the part that's not working): "@feathersjs/authentication": "^2.1.5", "@feathersjs/authentication-client": "^1.0.2", "@feathersjs/authentication-local": "^1.2.1", "@feathersjs/authentication-oauth2": "^1.1.0", "@feathersjs/client": "^3.1.2", "@feathersjs/express": "^1.1.2", "@feathersjs/feathers": "^3.0.5", "@feathersjs/rest-client": "^1.3.3", "@feathersjs/socketio": "^3.0.2", "@feathersjs/socketio-client": "^1.0.2", NodeJS version:
node -v v6.14.3 nginx version: nginx/1.14.0
Operating System: centos 7 Browser Version: Chrome 67.0.3396.87 / android 7.0
Module Loader: webpack