如何验证输入值与预定义值相同?

时间:2019-04-15 15:37:29

标签: azure-ad-b2c

我正在尝试验证用户输入的电子邮件验证码与另一个技术资料先前返回的验证码相同。当用户输入正确的代码时,此旅程步骤将按预期工作,但是当用户输入错误的代码时,该旅程步骤将挂起。我究竟做错了什么。这是我的旅行步骤执行的技术政策:

        <TechnicalProfile Id="EnterEmailVerifyCode">
      <DisplayName>Email entry</DisplayName>
      <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
      <Metadata>
        <Item Key="IpAddressClaimReferenceId">IpAddress</Item>
        <Item Key="ContentDefinitionReferenceId">api.localaccountsignup</Item>
        <Item Key="language.button_continue">Continue</Item>
      </Metadata>
      <CryptographicKeys>
        <Key Id="issuer_secret" StorageReferenceId="B2C_1A_TokenSigningKeyContainer" />
      </CryptographicKeys>
      <InputClaims>
        <InputClaim ClaimTypeReferenceId="email" />
        <InputClaim ClaimTypeReferenceId="emailVerificationCodeEntered" />
      </InputClaims>
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="emailVerificationCodeEntered" />
      </OutputClaims>
      <OutputClaimsTransformations>
         <OutputClaimsTransformation ReferenceId="AssertEmailVerificationCodesAreEqual" />
      </OutputClaimsTransformations>
    </TechnicalProfile> 

1 个答案:

答案 0 :(得分:1)

自我声明的技术资料必须invoke the claims transformation as a validation technical profile

声明一个声明转换技术简介,以调用声明转换:

<TechnicalProfile Id="ValidateEmailVerificationCodes">
  <DisplayName>Validate Email Verification Codes</DisplayName>
  <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.ClaimsTransformationProtocolProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
  <InputClaims>
    <InputClaim ClaimTypeReferenceId="emailVerificationCodeEntered" />
    <InputClaim ClaimTypeReferenceId="emailVerificationCodeGenerated" />
  </InputClaims>
  <OutputClaims>
    <OutputClaim ClaimTypeReferenceId="emailVerificationCodeEntered" />
  </OutputClaims>
  <OutputClaimsTransformations>
    <OutputClaimsTransformation ReferenceId="AssertEmailVerificationCodesAreEqual" />
  </OutputClaimsTransformations>
  <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
</TechnicalProfile>

然后从自我声明的技术档案中调用此声明转换技术档案作为验证技术档案:

<TechnicalProfile Id="EnterEmailVerifyCode">
  ...
  <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
  <Metadata>
    ...
    <Item Key="UserMessageIfClaimsTransformationStringsAreNotEqual">The verification code is invalid</Item>
  </Metadata>
  <InputClaims>
    <InputClaim ClaimTypeReferenceId="email" />
    <InputClaim ClaimTypeReferenceId="emailVerificationCodeEntered" />
  </InputClaims>
  <OutputClaims>
    <OutputClaim ClaimTypeReferenceId="emailVerificationCodeEntered" />
  </OutputClaims>
  <ValidationTechnicalProfiles>
    <ValidationTechnicalProfile ReferenceId="ValidateEmailVerificationCodes" />
  </ValidationTechnicalProfiles>
</TechnicalProfile>

UserMessageIfClaimsTransformationStringsAreNotEqual 指定在声明转换引发错误时显示的错误消息。