veliovgroup / Meteor-Files

🚀 Upload files via DDP or HTTP to ☄️ Meteor server FS, AWS, GridFS, DropBox or Google Drive. Fast, secure and robust.
https://packosphere.com/ostrio/files
BSD 3-Clause "New" or "Revised" License
1.11k stars 166 forks source link

After disconnect and reconnect the userId is null in protected #891

Open aertms opened 3 weeks ago

aertms commented 3 weeks ago

First of all thanks for a great library! I'm having an issue that if the app goes offline for a moment and comes back online (can be simulated with Meteor.disconnect() and Meteor.reconnect() ), the this.userId in the protected method on the server is null. I checked that the x_mtok cookie is set and it's correctly updated to the new session id after the reconnect. I checked in the server.js, in the _getUserDefault() when getting the cookie it gets the old session id for the session that doesn't exist anymore, so it can't find the user. What I would expect is that it returns the new session id so it finds the user. When I refresh the page everything is working again.

I'm using ostrio:files version 2.3.3 on Linux in a single server setup. I created a very simple meteor app to reproduce it here: https://github.com/aertms/mfiles You can login with user test and password test. If you upload an image file when running the small app it shows below. Now if you run Meteor.disconnect() and then Meteor.reconnect() in the browser console the image is not shown anymore, it returns a 401 code. After a refresh it's shown again.

I'm not sure if this is a bug or if there is an issue with my implementation. Or is this expected and I need to work around it?