Data permission is stored for a client who is not logged in using Meteor Auth, and then saved at login

I have a simple form that captures data from a user. This is just one field and date stamp to track weight on a daily basis.

I use the Meteor authorization package. When a user logs in, I just keep the UserID in the list and then filter the collection for that user ID.

This is normal if I force users to log in before they use the system.

But I would like users to try the system first. That way, they can save 3 or 4 rows of data, and then decide to create an account and save. In the short term, I would just like to save data from this current session (so if they close the browser without saving, their data will be lost). At the second stage, I would like the data to be saved so that if they are not saved, but returned the next day in the same browser, they can still decide to save their data against a permanent account.

I'm currently going to save uuid instead of the standard Meteor.userId for temporary users, and then just replace this value with your new Meteor.UseriD. Long-term storing of a random number as a user ID and storing this data in a permanent client cache, and then overwriting with Meteor.UserID when creating an account.

But I'm a beginner and would like to know if there is a more elegant way to achieve these two goals:

1) Allows the user to record some data that only they can see. Then save this when they want to create an account. 2) Allows the user to record some data that is stored in all sessions. Then save this data when they want to create an account.

+7
source share
1 answer

If you use the meteorite packet manager, you can use the anonymous plugin https://github.com/tmeasday/meteor-accounts-anonymous

These are just two small files, so you can simply add them directly to your project.

And then after registering with transefer user information.

+2
source

All Articles