繁体   English   中英

当用户名不是电子邮件地址时,两因素身份验证不将代码发送到电子邮件

[英]Two factor authentication not sending code to email when UserName is not an email address

我正在通过电子邮件使用Owin Identity 2.0进行两因素身份验证,由于我的ApplicationUser模型具有UserName和Email属性,因此在发送电子邮件时遇到问题。 如果UserName不是电子邮件地址,则代码不会发送到电子邮件地址,但是如果UserName是电子邮件地址,则可以正常工作。 任何可能的解决方案将不胜感激。

if (!ModelState.IsValid)
        {
            return BadRequest();
        }
        try
        {
            if (await SignInManager.SendTwoFactorCodeAsync(model.SelectedProvider))
            {
                Logger.Info("Email sent to " + model.UserName);
                return new { Sent = true };
            }
            Logger.Info("Email not sent to " + model.UserName);
        }
        catch (Exception e)
        { Logger.Error(e.Message); }
        return new { Sent = false };

您说,您有一个UserName属性和一个Email属性。 为什么不只使用电子邮件地址而不是用户名呢?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM