Get user outside a service #261
Comments
I am not sure what you mean? On the server for each method call the user that makes it is stored in |
I have 2 parts, one with feathers and another before that manages other actions (not REST), and I wish I could have access to the user connected when I am not in service and I do not have access to the hooks. After login I have the current user, my goal is to be able to recover after a refresh of the page and the server side rendering which is enabled |
This will be possible in the next version but for now you should be able to use the decode-token and populate-user Express middleware from that version. |
I saw decode-token Express middleware but I don't have |
@bertho-zero, If you're feeling brave, you can also try installing the pre-release version of |
It works well in real-time but not in rest, I don't understand.. I have : app.authenticate({
type: 'local',
email: data.email,
password: data.password
}).then(result => {
console.log(app.get('token')); // -> the JWT
console.log(app.get('user')); // -> the user
return result;
}) and both I continued to seek the cause edit: This is my log (feathers-*) when try to login in rest
|
I solved the problem with the following authentication config : ...
local: {
successHandler: authConfig => (req, res, next) => next
}
... Otherwise I lose the user and the token during the redirect, this is maybe due to cookies: {
enable: true,
'feathers-jwt': {
maxAge: 60 * 60 * 24 * 1000 // One day
}
} edit: I had not seen, cookies are not sending in XHR request, I just left |
I use it in this repo: https://github.com/bertho-zero/react-redux-universal-hot-example/ |
I can connect, edit a client-side cookie and remain connected to refresh the page, but the socket that reconnects, he is not identified with the user. Would you know how to reconnect the socket to the current user with token? |
@bertho-zero I think this is what you need: #272 (comment) |
Thanks, what I would like is not on a basic connection but a new connection after refresh the page. I tried the same thing at
Yet this is the same token for the http connection when retrieve the page, I do this in the client: socket.on('connect', () => {
app.authenticate();
}); And I've the following configuration:
|
How to get current connected user outside a service ?
I have this code :
And in my
actionsHandler
after loginreq.feathers
= only{ provider: 'rest' }
andreq.isAuthenticated()
=false
My auth config is the following:
And I connect like this:
ps: The cookie is never after login
The text was updated successfully, but these errors were encountered: