会员资格从 ID 切换为电子邮件
目前我有一个网站(asp.net 3.5),它使用唯一的 ID 进行登录。 如果可能的话,我需要将其切换为使用电子邮件。 我将创建所有新帐户,以便我可以清除成员资格表并导入所有用户信息。
我们正在从部门的通用登录切换到个人帐户。
任何正确方向的链接或指针将不胜感激。
Currently I have a site (asp.net 3.5) that uses a unique ID for the login. I am going to need to switch it to use emails if possible. I am going to be creating all new accounts so I can wipe the membership table clean and import all the user info.
We are switching from generic logins for departments to individual accounts.
Any links or pointers in the right direction would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以这就是你应该做的。
如果您要创建整个用户群,只需擦除当前的用户群并告诉用户使用电子邮件创建新用户,只要您在报名表上验证这一点,就可以了。
现在,如果您已经拥有用户群,那么情况会稍微复杂一些。
首先验证每个当前用户是否具有有效的不同电子邮件,然后您必须更改 aspnet_Users 表上的 2 列,这些列是 UserName 和 LoweredUserName。
如果第一步是真的,那应该很简单,只需对每个 aspnetMembership 行执行一个循环,获取电子邮件列并将其设置为 UserName,然后将 LoweredEmail 列设置为 LoweredUserName。
哒哒哒哒!
现在您已将其全部迁移到新模型,对于新条目,请确保条目表单将用户名验证为电子邮件,为此您可以使用正则表达式。
So here is what you should do.
If you are creating a entire user base just wipe of the current ones and tell users to create the new user with a email, as long as you validate that on the entry form you are going to be good.
Now if you already have a user base, then is a little more complicated.
First verify that every current user has a valid distinct email, then you have to change 2 columns on the aspnet_Users table, the columns are UserName, and LoweredUserName.
That should be simple if the first step is true, just do a loop for every aspnetMembership row, get the column Email and set as UserName, then get the column LoweredEmail a set as LoweredUserName.
Ta daaaaaa!
Now you have it all migrated to the new model, for new entries, make sure that the entry form validates the UserName to be an email, for that you can use RegEx.