我想在用户访问B2C忘记的密码页面时显示一条自定义消息。当他们输入自己的电子邮件地址而未找到其“电话号码”时,它应该仅在“继续/取消”按钮下显示一条错误消息,显示诸如“未注册,请联系支持”(也可以通过电子邮件文本框)如果在其下有太多事情要做,通常会出现错误消息)
如果电话号码存在或不存在,我将执行用户旅程和业务流程步骤来检测先决条件。但不确定如何执行此自定义错误消息。以下步骤的顺序2是需要该步骤才能显示该错误消息并完成(不执行其他步骤)的步骤
<UserJourney Id="PasswordReset">
<OrchestrationSteps>
<OrchestrationStep Order="1" Type="ClaimsExchange">
<ClaimsExchanges>
<ClaimsExchange Id="PasswordResetUsingEmailAddress" TechnicalProfileReferenceId="LocalAccountDiscoveryUsingEmailAddress" />
</ClaimsExchanges>
</OrchestrationStep>
<OrchestrationStep Order="2" Type="ClaimsExchange">
<Preconditions>
<Precondition Type="ClaimsExist" ExecuteActionsIf="true">
<Value>phonenumber</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
</Preconditions>
<ClaimsExchanges>
<ClaimsExchange Id="PasswordResetUsingEmailAddressExchange" TechnicalProfileReferenceId="LocalAccountDiscoveryUsingEmailAddressOTP" />
</ClaimsExchanges>
</OrchestrationStep>
..........
我认为我们可以通过在自定义配置文件中结合使用UserMessageIfClaimsPrincipalDoesNotExist和RaiseErrorIfClaimsPrincipalDoesNotExist之类的方法来做到这一点。但是,只是寻找一个捆绑在一起的例子即可。
答案 0 :(得分:2)
您可以将声明转换构建为:
在检索用户帐户时,必须引用这些声明转换,以便在第一步中显示错误消息。
要确定电话号码声明是否存在,请使用a DoesClaimExist claims transformation:
<ClaimsTransformation Id="DoesPhoneNumberExist" TransformationMethod="DoesClaimExist">
<InputClaims>
<InputClaim ClaimTypeReferenceId="phoneNumber" TransformationClaimType="inputClaim" />
</InputClaims>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="phoneNumberDoesExist" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
要确保电话号码确实存在,请使用a AssertBooleanClaimIsEqualToValue claims transformation:
<ClaimsTransformation Id="EnsurePhoneNumberDoesExist" TransformationMethod="AssertBooleanClaimIsEqualToValue">
<InputClaims>
<InputClaim ClaimTypeReferenceId="phoneNumberDoesExist" TransformationClaimType="inputClaim" />
</InputClaims>
<InputParameters>
<InputParameter Id="valueToCompareTo" DataType="boolean" Value="true" />
</InputParameters>
</ClaimsTransformation>
要显示该错误消息,您必须从 AAD-UserReadUsingEmailAddress 技术资料中调用声明转换:
<TechnicalProfile Id="AAD-UserReadUsingEmailAddress">
...
<OutputClaims>
...
<OutputClaim ClaimTypeReferenceId="phoneNumber" />
</OutputClaims>
<OutputClaimsTransformations>
<OutputClaimsTransformation ReferenceId="DoesPhoneNumberExist" />
<OutputClaimsTransformation ReferenceId="EnsurePhoneNumberDoesExist" />
</OutputClaimsTransformations>
<IncludeTechnicalProfile ReferenceId="AAD-Common" />
</TechnicalProfile>
然后,您必须在 LocalAccountDiscoveryUsingEmailAddress 技术资料中包含 UserMessageIfClaimsTransformationBooleanBooleanIsNotEqual 元数据:
<TechnicalProfile Id="LocalAccountDiscoveryUsingEmailAddress">
...
<Metadata>
...
<Item Key="UserMessageIfClaimsTransformationBooleanValueIsNotEqual">Whoops, you aren't registered, contact Support.</Item>
</Metadata>
...
<ValidationTechnicalProfiles>
<ValidationTechnicalProfile ReferenceId="AAD-UserReadUsingEmailAddress" />
</ValidationTechnicalProfiles>
</TechnicalProfile>