Custom Verification Code/Token in Asp .Net Identity

∥☆過路亽.° 提交于 2020-01-07 02:44:11

问题


I need to create short code (6 digits) for Email Confirmation using Asp.Net Identity. Currently, if I use

"GenerateEmailConfirmationTokenAsync" 

it provides me with very long code instead of this I want to generate a code which is only 6 digit in length. Is there any way to achieve this how can I extend identity to provide such a feature. any leads towards this will be helpful.

Thanks


回答1:


Yes you can. Check this SO answer for details.

Basically you have to create a class inheriting IUserTokenProvider<TUser, TKey> and implement those two methods: GenerateAsync and ValidateAsync.

There you will write the code to generate and validate your six characther token. The same token will be used everywhere inside the ASP.NET Identity without any other code change.



来源:https://stackoverflow.com/questions/36963854/custom-verification-code-token-in-asp-net-identity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!