Validate restriction in Azure AD B2C custom policy

Viewed 205

I have the following ClaimType in a custom policy to test out collecting user timezone during sign up:

  <ClaimType Id="extension_timezone">
    <DisplayName>Timezone</DisplayName>
    <DataType>string</DataType>
    <UserHelpText>Enter your timezone</UserHelpText>
    <UserInputType>DropdownSingleSelect</UserInputType>
    <Restriction>
      <Enumeration Text="(UTC-08:00) Pacific Time (US &amp; Canada)" Value="(UTC-08:00) Pacific Time (US &amp; Canada)" SelectByDefault="false" />
      <Enumeration Text="(UTC-06:00) Central Time (US &amp; Canada)" Value="(UTC-06:00) Central Time (US &amp; Canada)" SelectByDefault="false" />
      <Enumeration Text="(UTC+00:00) Dublin, Edinburgh, Lisbon, London" Value="(UTC+00:00) Dublin, Edinburgh, Lisbon, London" SelectByDefault="true" />
      <Enumeration Text="(UTC+12:00) Auckland, Wellington" Value="(UTC+12:00) Auckland, Wellington" SelectByDefault="false" />
    </Restriction>
  </ClaimType>  

This displays correctly in the sign up flow but I have noticed that the input is not validated against the restriction. Steps:

  1. Select item from drop-down
  2. Use browser tools (e.g. Chrome DevTools) to change the value of the selected option
  3. Submit the form

I would expect there to be validation to check that the submitted value matches one of the enumeration entries, but this does not happen. I can include extension_timezone in the output claims and see that the value reflects the changes I made that do not match any of the enumeration options.

1 Answers

You can add your own validation rules using jQuery which is loaded by both v1 and v2 policies.

Please refer this document for gudelines and samples of using Javascript

Related