graphql-jwt-tutorial icon indicating copy to clipboard operation
graphql-jwt-tutorial copied to clipboard

Only allows one user to be logged in

Open Yamaha32088 opened this issue 5 years ago • 1 comments

I appreciate all the work that went into this and the tutorial it was very insightful. I think currently though with the code implementation in this repo it will not allow for multiple different people to be logged in. Inside of auth.js you set inMemoryToken but it is shared across all users. For example if I start the app in development mode and login it will set inMemoryToken just fine. Now if I open another Browser in incognito it thinks I am still logged in as the other user because inMemoryToken already exists.

Do you know of a workaround for this?

Yamaha32088 avatar May 13 '20 18:05 Yamaha32088

It appears that it may be caused by the way node is caching the module on the very first request. Node is retrieving the tokens properly and storing them inside inMemoryToken as expected but then this gets cached and reused on every subsequent request to node. The client side works as expected but the server side does not.

Yamaha32088 avatar May 14 '20 14:05 Yamaha32088