【问题标题】:Two factor authentication not sending code to email when UserName is not an email address当用户名不是电子邮件地址时,两因素身份验证不向电子邮件发送代码
【发布时间】:2018-09-19 05:48:24
【问题描述】:

我正在使用 Owin 身份 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 };

【问题讨论】:

    标签: c# owin asp.net-identity-2


    【解决方案1】:

    您说过,您有一个 UserName 属性和一个 Email 属性。为什么不直接使用电子邮件地址而不是用户名作为收件人?

    【讨论】:

    • 它的要求,用户可以使用电子邮件或用户名登录。
    猜你喜欢
    • 2014-09-18
    • 2011-12-29
    • 2012-07-14
    • 1970-01-01
    • 2014-12-31
    • 2018-08-07
    • 1970-01-01
    • 2015-06-25
    • 2019-08-29
    相关资源
    最近更新 更多