CombinedSignInSignUp 步骤上的模式消息配置不正确

Incorrect pattern message configuration on CombinedSignInSignUp step

使用为该字段定义的无效模式在 CombinedSignInSignUp 旅程步骤中输入密码会导致在表单的输入部分上方显示以下错误消息:

Incorrect pattern for [Password]

有没有办法配置此错误消息,使其更加用户友好?

是的,但该消息可用于多个字段。

请参阅本指南:Azure Active Directory B2C: Using language customization


  1. 下载当前内容:

  2. 编辑 json 并重新上传:

    {
        "ElementType": "ErrorMessage",
        "ElementId": null,
        "StringId": "UserMessageIfIncorrectPattern",
        "Value": "Incorrect pattern for: {0}"
    }
    

感谢spottedmahn提供有关语言自定义的信息。由于我使用的是自定义 B2C 策略,因此我无法通过 Azure 门户编辑语言功能。

我发现 WingTipGames 示例中的 this policy 展示了如何实现我想要的。

我向我的 ContentDefinition 添加了一个 LocalizedResourceReference,如下所示:

<ContentDefinition Id="api.combinedsignupsignin">
    <LoadUri>https://www.mywebsite.net/login</LoadUri>
    <RecoveryUri>~/common/default_page_error.html</RecoveryUri>
    <DataUri>urn:com:microsoft:aad:b2c:elements:unifiedssp:1.1.0</DataUri>
    <Metadata>
      <Item Key="DisplayName">Signin and Signup</Item>
    </Metadata>
    <LocalizedResourcesReferences MergeBehavior="Prepend">
      <LocalizedResourcesReference Language="en" Url="https://mywebsite.net" LocalizedResourcesReferenceId="api.combinedsignupsignin.en" />
    </LocalizedResourcesReferences>
  </ContentDefinition>

然后我在 BuildingBlocks 中添加了以下本地化部分:

<Localization Enabled="true">
  <SupportedLanguages DefaultLanguage="en" MergeBehavior="ReplaceAll">
    <SupportedLanguage>en</SupportedLanguage>
  </SupportedLanguages>
  <LocalizedResources Id="api.combinedsignupsignin.en">
    <LocalizedStrings>
      <LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfIncorrectPattern">Please enter a valid password</LocalizedString>
    </LocalizedStrings>
  </LocalizedResources>
</Localization>

这导致我在屏幕上收到所需的错误消息:

"Please enter a valid password"