【问题标题】:Azure AD B2C custom Password reset policy won't validate e-mail with + char\signAzure AD B2C 自定义密码重置策略不会使用 + char\sign 验证电子邮件
【发布时间】:2020-02-26 23:21:13
【问题描述】:

用户可以使用包含+ 的电子邮件使用 Azure AD B2C 进行注册和登录。但是,当单击登录页面上的“忘记密码”链接并输入带有+ 字符的电子邮件时,会显示以下错误:

我在 Azure 的反馈网站上看到了 2 个相关问题:

allow plus sign in email addresses [用户 Naud van Onna 的评论与此问题相符。 ]

我看到在电子邮件地址中使用“+”号成功注册 也是。不幸的是,密码重置功能不起作用 使用带有“+”符号的电子邮件地址。

Support plus-addressing in emails, which is invaluable for testing [ 在这篇文章中提到了描述我们情况的电子邮件sub-addressing 功能。我们使用+ 电子邮件地址来测试我们的应用程序。 ]

自定义策略 .xml 文件中是否有我可以输入自定义正则表达式来验证此电子邮件地址并允许使用 + 符号的位置?

我在TrustFrameworkBase.xml 文件中看到了<TechnicalProfile Id="LocalAccountDiscoveryUsingEmailAddress">,但我不确定在哪里修改它...

<!-- This technical profile forces the user to verify the email address that they provide on the UI. Only after email is verified, the user account is
        read from the directory. -->
        <TechnicalProfile Id="LocalAccountDiscoveryUsingEmailAddress">
.
.
.

【问题讨论】:

    标签: regex azure-ad-b2c email-validation forgot-password reset-password


    【解决方案1】:

    嗯...经过更多研究后,我在电子邮件ClaimType 内的TrustFrameworkBase.xml 中发现了错误消息“请输入有效的电子邮件地址。”。

    <ClaimType Id="email">
    <DisplayName>Email Address</DisplayName>
    <DataType>string</DataType>
    <DefaultPartnerClaimTypes>
      <Protocol Name="OpenIdConnect"
        PartnerClaimType="email" />
    </DefaultPartnerClaimTypes>
    <UserHelpText>Email address that can be used to contact you.</UserHelpText>
    <UserInputType>TextBox</UserInputType>
    <Restriction>
      <Pattern RegularExpression="^[a-zA-Z0-9.!#$%&amp;'^_`{}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$"
        HelpText="Please enter a valid email address." />
    </Restriction>
    </ClaimType>
    

    这个正则表达式

    ^[a-zA-Z0-9.!#$%&'^_`{}~-]+@[a-zA-Z0-9-]+(?:.[a-zA-Z0 -9-]+)*$

    是验证电子邮件的那个...我们只需要对其进行调整,使其接受+ 符号,如下所示:

    ^[a-zA-Z0-9.+!#$%&'^_`{}~-]+@[a-zA-Z0-9-]+(?:.[a-zA- Z0-9-]+)*$

    关于 ClaimsSchema 的 Microsoft 文档。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-28
      • 2022-11-18
      • 2021-01-08
      • 2021-02-05
      • 1970-01-01
      • 2018-04-02
      • 1970-01-01
      相关资源
      最近更新 更多