Localization of custom claim in Azure AD B2C custom policy - azure-ad-b2c

I have the following claim type in my relying party building block section:
<ClaimType Id="extension_mfaByPhoneOrEmail">
<DisplayName>Please select your preferred MFA method</DisplayName>
<DataType>string</DataType>
<UserInputType>RadioSingleSelect</UserInputType>
<Restriction>
<Enumeration Text="Phone" Value="phone" SelectByDefault="true" />
<!-- <Enumeration Text="Email " Value="email" SelectByDefault="false" /> -->
</Restriction>
</ClaimType>
I'm not able to add the localization for another language, I have already set the trustframeworklocalization.xml file and it'w works for the other parts of the code.

problem solved in part, I added on the selfasserted content definition id the following rows:
<!-- Self Asserted localized strings (English) -->
<LocalizedResources Id="api.selfasserted.en">
<LocalizedStrings>
<LocalizedString ElementType="ClaimType" ElementId="extension_mfaByPhoneOrEmail" StringId="DisplayName">Please select your preferred MFA method</LocalizedString>
</LocalizedStrings>
</LocalizedResources>

problem solved, i added on the selfasserted content definition id the following rows:
<LocalizedResources Id="api.selfasserted.en">
<LocalizedCollections>
<LocalizedCollection ElementType="ClaimType" ElementId="extension_mfaByPhoneOrEmail" TargetCollection="Restriction">
<Item Text="Phone" Value="phone" />
<Item Text="Email" Value="email" />
</LocalizedCollection>
</LocalizedCollections>
<LocalizedStrings>
<LocalizedString ElementType="ClaimType" ElementId="extension_mfaByPhoneOrEmail" StringId="DisplayName">Please select your preferred MFA method</LocalizedString>
</LocalizedStrings>
</LocalizedResources>

Related

How to dynamically display data in B2C sign up page with a localized String?

So I am trying to display a query parameter in my HTML page. I have not had an issue doing this is a claim, I created this.
<ClaimsSchema>
<ClaimType Id="ID">
<DisplayName>ID</DisplayName>
<DataType>string</DataType>
</ClaimType>
</ClaimsSchema>
Then in my relaying party I have this,
<OutputClaim ClaimTypeReferenceId="ID" AlwaysUseDefaultValue="true" DefaultValue="{OAUTH-KV:ID}" />
and in the sign in URL we have &ID=12345
What we are trying to do is send out sign up links with a specific ID value. Then when they make it to the sign in / sign up page the join now link has that ID appended to it.
So like www.mycompany.com/register/id=12345
I have localized the strings in self asserted page.
<Localization>
<LocalizedResources Id="api.selfasserted">
<LocalizedStrings>
<LocalizedString ElementType="UxElement" StringId="disclaimer_msg_intro">Dont have an account?</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="disclaimer_link_1_text">Join Now</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="disclaimer_link_1_url">http://www.mycompany.com/register/id=</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
</Localization>
Is there a way to inject that claim in that link?
I know i can do this with JS... i am trying to avoid using Javascript.
It’s not possible to do dynamic claim resolving in localised elements function. You’re going to have to use JS.

Azure AD B2C Self-service password reset showing wrong title

When enabling this new self service password reset, it shows wrong titles on the login page.
https://learn.microsoft.com/en-us/azure/active-directory-b2c/add-password-reset-policy?pivots=b2c-custom-policy#self-service-password-reset-recommended
It shows these:
Sign in with your social account
OR
Sign in with your sign in name
But I'm not using any social account, only local account, the Sign in with your social account is empty.
I also tried on this sample, removing facebook as social account, having only local account, however it keeps the empty Sign in with your social account.
https://github.com/azure-ad-b2c/samples/tree/master/policies/embedded-password-reset
Anyone managed to enable self service password reset for local account only and having the correct title Sign in with your sign in name?
This has been fixed in newest version of content definition. In TrustFrameworkBase file use for api.signuporsignin the following DataUri:
<DataUri>urn:com:microsoft:aad:b2c:elements:contract:unifiedssp:2.1.5</DataUri>
There are two ways to approach this:
Using the Localization features of the Identity Experience Framework. This will allow you to modify the UxElements on your Content Definitions. More information can be found at https://learn.microsoft.com/en-us/azure/active-directory-b2c/localization.
Completely customize the User Interface - https://learn.microsoft.com/en-us/azure/active-directory-b2c/customize-ui-with-html?pivots=b2c-custom-policy
It took me a minute to test this on one of my policies, but this is what I added to my Sign In/Sign Up page to verify the localization.
<BuildingBlocks>
<Localization Enabled="true">
<SupportedLanguages DefaultLanguage="en" MergeBehavior="ReplaceAll">
<SupportedLanguage>en</SupportedLanguage>
</SupportedLanguages>
<LocalizedResources Id="api.selfasserted.en">
<LocalizedStrings>
<LocalizedString ElementType="UxElement" StringId="local_intro_generic">Brad</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
</Localization>
</BuildingBlocks>
And then updated my Content Definition:
<ContentDefinition Id="api.selfasserted">
<LoadUri>~/tenant/templates/AzureBlue/selfAsserted.cshtml</LoadUri>
<RecoveryUri>~/common/default_page_error.html</RecoveryUri>
<DataUri>urn:com:microsoft:aad:b2c:elements:contract:selfasserted:2.1.2</DataUri>
<Metadata>
<Item Key="DisplayName">Collect information from user page</Item>
</Metadata>
<LocalizedResourcesReferences>
<LocalizedResourcesReference Language="en" LocalizedResourcesReferenceId="api.selfasserted.en"/>
</LocalizedResourcesReferences>
</ContentDefinition>

Localizing the API response in Custom Police Azure ADB2C

I have implemented localization in Azure ADB2C custom policy.
<ClaimType Id="signInName">
<DisplayName>Please enter your email</DisplayName>
<DataType>string</DataType>
<UserHelpText>Enter your email address to signin</UserHelpText>
<Restriction>
<Pattern RegularExpression="^[a-zA-Z0-9_.+-]+#[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$"/>
</Restriction>
</ClaimType>
<Localization Enabled="true">
<SupportedLanguages DefaultLanguage="en" MergeBehavior="ReplaceAll">
<SupportedLanguage>en</SupportedLanguage>
<SupportedLanguage>es</SupportedLanguage>
</SupportedLanguages>
<LocalizedResources Id="en">
<LocalizedStrings>
<LocalizedString ElementType="ClaimType" ElementId="signInName" StringId="DisplayName">Please enter your email</LocalizedString>
<LocalizedString ElementType="ClaimType" ElementId="signInName" StringId="UserHelpText">Enter your email address to signin</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
<LocalizedResources Id="es">
<LocalizedStrings>
<LocalizedString ElementType="ClaimType" ElementId="signInName" StringId="DisplayName">Por favor introduzca su correo electrónico</LocalizedString>
<LocalizedString ElementType="ClaimType" ElementId="signInName" StringId="UserHelpText">Ingrese su dirección de correo electrónico para iniciar sesión</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
</Localization>
Everything is working as expected but when the login button is clicked, an API call is made and the response is always in English. Also the query string parameter to indicate the language is not sent in the API call. Any help is greatly appreciated.
You need to first find what is the string ID which is showing this error.
We support these IDs for localization which you might have customized in your policies.
Then, once you know which ID is being used for your error message, you can add a LocalizedString element like below (For example, I am assuming the ElementType is ErrorMessage and StringID is DefaultMessage):
<LocalizedString ElementType="ErrorMessage" StringId="DefaultMessage">#Invalid username or password.</LocalizedString>
You can find out different examples of the same here: https://learn.microsoft.com/en-us/azure/active-directory-b2c/custom-policy-localization

Azure B2C Custom Policy Has Create Button for SignUpSignIn and ProfileEdit Policies

I am currently experiencing a problem with Azure B2C IEF Custom Policy. In my "ProfileEdit" UserJourney The user is presented with the sign-in screen. The problem here is that the continue button is actually labeled "Create" After the user signs in, they are presented with a Edit Profile Page. But again, the continue button is labeled as create.
I have done a lot of research. I could not find anything in stackoverflow and I have reviewed Microsoft Documentation and also ensured that the DataURIs are correct for the ContentDefinition.
The current Data URI is as follows:
urn:com:microsoft:aad:b2c:elements:contract:selfasserted:1.1.0
Any guidance would be greatly appreciated.
if you don't want to go with localization. You can still update button/ label values inside Metadata of relevant technical profiles.
For your scenario
Add new Metadata Item in Base file technical profile
SelfAsserted-LocalAccountSignin-Email like below
<Metadata>
---
<Item Key="language.button_continue">Continue</Item>
</Metadata>
You can customize any element text using localization.
The first step is to enable localization for English and any other languages to be supported:
<BuildingBlocks>
...
<ContentDefinitions />
<Localization>
<SupportedLanguages DefaultLanguage="en">
<SupportedLanguage>en</SupportedLanguage>
</SupportedLanguages>
</Localization>
</BuildingBlocks>
The second step is to define the localized strings for each supported language for each page definition:
<BuildingBlocks>
...
<Localization>
<SupportedLanguages />
<LocalizedResources Id="api.selfasserted.profileupdate.en">
<LocalizedStrings>
<LocalizedString ElementType="UxElement" StringId="button_continue">Update</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
</Localization>
</BuildingBlocks>
The last step is to declare references from the page definition to the localized resources:
<BuildingBlocks>
...
<ContentDefinitions>
<ContentDefinition Id="api.selfasserted.profileupdate">
...
<LocalizedResourcesReferences MergeBehavior="Prepend">
<LocalizedResourcesReference Language="en" LocalizedResourcesReferenceId="api.selfasserted.profileupdate.en" />
</LocalizedResourcesReferences>
</ContentDefinition>
</ContentDefinitions>
<Localization />
</BuildingBlocks>

Incorrect pattern message configuration on CombinedSignInSignUp step

Entering a password on a CombinedSignInSignUp journey step using an invalid pattern defined for that field results in the following error message being displayed above the entry section of the form:
Incorrect pattern for [Password]
Is there a way to configure this error message so it can be made more user friendly?
Yes but that message can be used for multiple fields.
See this guide: Azure Active Directory B2C: Using language customization.
Download the current content:
Edit the json and re-upload it:
{
"ElementType": "ErrorMessage",
"ElementId": null,
"StringId": "UserMessageIfIncorrectPattern",
"Value": "Incorrect pattern for: {0}"
}
Thanks to spottedmahn for the information on language customisation. As I am using custom B2C policies I can't edit the language features through the Azure Portal.
I found that this policy from the WingTipGames example shows how to achieve what I want.
I added a LocalizedResourceReference to my ContentDefinition as follows:
<ContentDefinition Id="api.combinedsignupsignin">
<LoadUri>https://www.mywebsite.net/login</LoadUri>
<RecoveryUri>~/common/default_page_error.html</RecoveryUri>
<DataUri>urn:com:microsoft:aad:b2c:elements:unifiedssp:1.1.0</DataUri>
<Metadata>
<Item Key="DisplayName">Signin and Signup</Item>
</Metadata>
<LocalizedResourcesReferences MergeBehavior="Prepend">
<LocalizedResourcesReference Language="en" Url="https://mywebsite.net" LocalizedResourcesReferenceId="api.combinedsignupsignin.en" />
</LocalizedResourcesReferences>
</ContentDefinition>
I then added this the following Localization section within BuildingBlocks:
<Localization Enabled="true">
<SupportedLanguages DefaultLanguage="en" MergeBehavior="ReplaceAll">
<SupportedLanguage>en</SupportedLanguage>
</SupportedLanguages>
<LocalizedResources Id="api.combinedsignupsignin.en">
<LocalizedStrings>
<LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfIncorrectPattern">Please enter a valid password</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
</Localization>
This resulted with me getting the desired error message on screen:
"Please enter a valid password"

Resources