I am working on SPA AngularJS application which allows users to collaborate on projects and stores history of edits for each user. The requirement is to allow unauthenticated users to manipulate data too. Once the user registers, I need to associate her history of edits with the newly created account. The backend is Django. What is the best option to track actions of anonymous users?
我正在开发SPA AngularJS应用程序,它允许用户在项目上进行协作并存储每个用户的编辑历史记录。要求是允许未经身份验证的用户也操纵数据。一旦用户注册,我需要将她的编辑历史与新创建的帐户相关联。后端是Django。跟踪匿名用户操作的最佳选择是什么?
- I can create “anonymous” user at the firs visit, issue JWT, store it in the browser and use to track all the user’s activity. Later on when registering user, just update her profile. The drawback is that there is a potential to get a lot of orphaned users that need to be periodically cleaned up. This is similar to https://github.com/danfairs/django-lazysignup, but adapted to work with https://github.com/GetBlimp/django-rest-framework-jwt.
- 我可以在第一次访问时创建“匿名”用户,发布JWT,将其存储在浏览器中并用于跟踪所有用户的活动。稍后注册用户时,只需更新她的个人资料。缺点是有可能让很多孤立的用户需要定期清理。这类似于https://github.com/danfairs/django-lazysignup,但适用于https://github.com/GetBlimp/django-rest-framework-jwt。
- Use JWT or cookie to track user session. Allow using session identifier instead of user key to track user’s activity. When creating real user update all references to the session with user’s pk.
- 使用JWT或cookie来跟踪用户会话。允许使用会话标识符而不是用户密钥来跟踪用户的活动。在创建真实用户更新时,使用用户的pk对会话进行所有引用。
Anything else?
还要别的吗?
1 个解决方案
#1
1
From my experience go for solution 1. The orphan user is often not a problem because from business plan point of view it's user and the more is better.
根据我的经验,寻求解决方案1.孤儿用户通常不是问题,因为从业务计划的角度来看,用户越多越好。
Also having only a notion of user is really simpler. They are users who haven't fully completed their profile that's all.
只有用户的概念也非常简单。他们是尚未完全完成其个人资料的用户。
#1
1
From my experience go for solution 1. The orphan user is often not a problem because from business plan point of view it's user and the more is better.
根据我的经验,寻求解决方案1.孤儿用户通常不是问题,因为从业务计划的角度来看,用户越多越好。
Also having only a notion of user is really simpler. They are users who haven't fully completed their profile that's all.
只有用户的概念也非常简单。他们是尚未完全完成其个人资料的用户。