0

I am currently implementing this example to use an rest API during the user registration.

The basic idea is that the API throws an 409 Conflict error to interrupt the registration.

// Can I return a special "StringId" or something here for localization?
return new ConflictObjectResult(new B2CResponseModel($"A verification email sent to you. Please open your mail box and click on the link. If you didn't receive the email, please click on the 'Send verification email' button.", HttpStatusCode.Conflict));

I want to show the user a message that is localized to their current language. I would prefer to do the localization within the custom policies, but I would also accept a solution within the API (would need to get the User Language for this).

Is there a way to do this localization? Like returning a StringId via API and using this within the policy?

I am also considering not returning an error from the API, to show the message in a new screen instead (like How to display error returned from custom REST API endpoint in a subsequent orchestration step?). However, localization options for this elude me as well.

Alex AIT
  • 17,361
  • 3
  • 36
  • 73

2 Answers2

1

In case anybody is looking for a way to send the user's locale to the REST API:

https://learn.microsoft.com/nb-no/azure/active-directory-b2c/claim-resolver-overview

        <TechnicalProfile Id="REST-API-SendVerificationEmail">
          <DisplayName>Sign-Up send link</DisplayName>
          <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
          <Metadata>
            <Item Key="ServiceUrl">https://xxxx</Item>
            <Item Key="AuthenticationType">None</Item>
            <Item Key="SendClaimsIn">Body</Item>
          </Metadata>
          <InputClaims>
            <InputClaim ClaimTypeReferenceId="email" />
            <InputClaim ClaimTypeReferenceId="userLanguage" DefaultValue="{Culture:LanguageName}" />
            <InputClaim ClaimTypeReferenceId="policyId" PartnerClaimType="policy" DefaultValue="{Policy:PolicyId}" />
            <InputClaim ClaimTypeReferenceId="scope" DefaultValue="{OIDC:scope}" />
            <InputClaim ClaimTypeReferenceId="clientId" DefaultValue="{OIDC:ClientId}" />
          </InputClaims>
          <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
        </TechnicalProfile>
Alex AIT
  • 17,361
  • 3
  • 36
  • 73
0

Hope this is similar to this

See the answer by Jas Suri. Pass the localisation parameter to API and return the localised message or can return an error code and based on that display translated message using policy itself.

Alex
  • 734
  • 6
  • 29