Azure B2C - Sign-in with non-English email addresses

Viewed 663

We are using a custom sign-up/sign-in policy with Azure B2C and are having trouble trying to sign-in with foreign language email addresses.

We have followed the Microsoft tutorials and have used the custom starter XML files here.

We initially found that we couldn't even SIGN-UP with a foreign language email address (such as 伊伊伊伊伊伊伊@伊伊伊.伊伊伊) but we noticed that there was some regex in the TrustFrameworkBase.xml starter file that we could manipulate:

  <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>

So we changed the regular expression and we could sign-up!

But then, when we tried to sign-IN with the account we just signed-up with we got a message saying "Please enter a valid email address".

I've tried this with a vanilla sign-up/sign-in policy out-the-box and I get the same thing. There's a regex pattern attribute on the HTML text box that looks like:

      <input type="email" id="logonIdentifier" name="Username or email address" pattern="^[a-zA-Z0-9.!#$%&amp;’'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$" placeholder="Email Address" value="" tabindex="1">

that prevents sign-in.

If I go in and remove this pattern regex I can actually sign-in, so I know it CAN work. I just need to remove this pattern attribute.

I must be missing something. Can anyone tell me what I need to configure to be able to sign-in with such an email address?

1 Answers

The email regex pattern for signIn is not pulled from "pattern" attribute in ClaimType from policy. That's why you are observing this behavior.

What you can do is by adding a language setting in technical profile metadata like following.

   <TechnicalProfile Id="SelfAsserted-LocalAccountSignin-Email">
      <Metadata>

        ...
        <Item Key="language.email_pattern">{desired_pattern}</Item>
      </Metadata>
      ….
    </TechnicalProfile>
Related