Asp .Net Identity中的自定义验证代码/令牌 [英] Custom Verification Code/Token in Asp .Net Identity

查看:144
本文介绍了Asp .Net Identity中的自定义验证代码/令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用Asp.Net Identity创建用于电子邮件确认的短代码(6位数字). 目前,如果我使用

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

"GenerateEmailConfirmationTokenAsync" 

它为我提供了很长的代码,而不是我想生成的代码只有6位数字. 有什么方法可以实现这一点,我如何扩展身份以提供这种功能.任何导致这种情况的线索都会有所帮助.

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.

谢谢

推荐答案

可以.查看 SO答案以获取详细信息.

Yes you can. Check this SO answer for details.

基本上,您必须创建一个继承IUserTokenProvider<TUser, TKey>的类并实现这两个方法:GenerateAsyncValidateAsync.

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

您将在此处编写代码以生成并验证您的六个字符令牌.相同的令牌将在ASP.NET标识内的任何地方使用,而无需任何其他代码更改.

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.

这篇关于Asp .Net Identity中的自定义验证代码/令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆