Closed chuan137 closed 7 years ago
@chuan137 the userId
is automatically included in the JWT payload. To get access to it you just need to do on the client is:
feathersClient.authenticate({
strategy: 'local',
email: 'admin@feathersjs.com',
password: 'admin'
})
.then(response => {
console.log('Authenticated!', response);
return feathersClient.passport.verifyJWT(response.accessToken);
})
.then(payload => {
console.log('JWT Payload', payload);
return feathersClient.service('users').get(payload.userId);
})
.then(user => {
feathersClient.set('user', user);
console.log('User', client.get('user'));
})
.catch(function(error){
console.error('Error authenticating!', error);
});
currently, I got an object with
{accessToken}
when authenticate successfully. it would be handy if the user's id is also returned for loading more info from the server. maybe it is already implemented?