实现非永久用户删除的最佳方法是什么?
我尝试永远不要从数据库中的重要表中删除实际记录,而是通过将相应字段设置为 True 将它们标记为已删除。但如果是会员资格,这种方法将阻止任何未来的用户重复使用“已删除”用户的用户名。用户名不会成为问题,但如果“已删除”的用户决定再次注册并尝试使用同一电子邮件怎么办?由于电子邮件在 ASP.NET 成员资格中也是唯一的,因此会抛出错误,表明该电子邮件已被使用(已被删除的帐户使用)。摆脱这种情况的最佳方法是什么?
提前致谢。
I try to never delete the actual records from the important tables in my database, instead mark them as Deleted by setting corresponding field to True. But in case of a membership this approach will prevent any future user of reusing the username of the "deleted" user. Username won't be a problem, but what if the "deleted" user decides to sign up again and tries to use the same email? Since the emails are also unique in asp.net membership it will throw an error that the email is already in use (by the deleted account). What is the best way out of this?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为使用活动标志效果很好。如果用户停用其帐户并再次注册,在检查电子邮件是否已存在后,您可以检查他们是否设置为非活动状态,然后重新激活其帐户。
I think using an active flag works well. If a users deactivates their account and signs up again, after you check if the email already exists you can then check if they are set to inactive and then offer to reactivate their account.
也许您需要一个代码路径来重新激活,而不是在删除后创建新帐户。 《魔兽世界》就是这么做的,而且《魔兽世界》不会错。
Perhaps you need a code path for re-activation, rather than new account creation after deletion. This is how WoW does it, and WoW can't be wrong.
如果您使用的是SqlMembershipProvider,只需锁定帐户并设置注释表明锁定是永久的。
这不涉及任何修改,仅涉及工作流程调整。
同样,这假设您使用的是库存会员堆栈。
If you are using SqlMembershipProvider, just lock the account and set a comment indicating that the lock is permanent.
This would involve no modifications, only workflow adjustment.
Again, this assumes that you are using a stock membership stack.
只需将用户名更改为“deleted001”或类似的名称即可。很多网站都这样做。
编辑
斯特凡的回答非常好......除非您希望他们能够基本上从您的网站上删除他们的识别信息。此时您需要重命名用户。
Just change the username to something like 'deleted001' or something like it. A lot of sites do this.
edit
Stefan's answer is pretty good... unless you want them to be able to basically remove their identifying information from your site. At which point you need to rename the user.