7

I have a simple form that captures data from the user. It is just a single field and a date stamp for tracking weight on a daily basis.

I am using the Meteor authorisation package. When a user is logged in I just save UserID into the list and then filter the collection for that User ID.

This is fine if I force users to login before they use the system.

But I would like to allow users to try the system first. So they might save 3 or 4 lines of data and then decide to create an account and save. In the short term I would like to just save the data from that current session (so if they shut their browser down without having saved, their data is lost). In Phase 2 I would like the data to persist so that if they don't save but come back the next day in the same browser they can still decide to save their data against a permanent account.

I am currently thinking of saving the uuid instead of the standard Meteor.userId for temporary users and then just replace this value with their new Meteor.UseriD. Longer term saving a random number as the user ID and saving this data to a persistent client cache and then overwriting with their Meteor.UserID when they create an account.

But I am a newbie and would like to know if there is a more elegant way of achieving these two goals:

1) Allowing the user to record some data, that only they can see. Then saving this when they choose to create an account. 2) Allowing the user to record some data, that persists across sessions. Then saving that data when they choose to create an account.

4

1 回答 1

2

如果您使用的是陨石包管理器,您可以使用 accounts-anonymous 插件https://github.com/tmeasday/meteor-accounts-anonymous

它只有两个小文件,因此您也可以直接将其添加到您的项目中。

然后一旦登录将用户信息传输过来。

于 2013-03-26T03:30:46.137 回答