azure-ad-b2c / samples

Azure AD B2C custom policy solutions and samples.
832 stars 596 forks source link

Localization for otp verification error #358

Closed maheshbthapa closed 2 years ago

maheshbthapa commented 2 years ago

I am implementing TOTP with custom policy. I am having an issue with localization for claimVerificationServerError. Initially this text div tag is empty <div id="claimVerificationServerError" class="error pageLevel" style="display: none;" aria-hidden="true"></div>

When I enter incorrect otp code I get error Wrong code entered, please try again. <div id="claimVerificationServerError" class="error pageLevel" style="display: block;" aria-hidden="false" role="alert" aria-live="polite" tabindex="1">Wrong code entered, please try again.</div>

I wanted to localize this text but I cannot seem to find the correct one. I tried with both ErrorMessage as claimVerificationServerError and UxElement as error_claimVerificationServerError.

kamilzzz commented 2 years ago

Unfortunately, this is undocumented but you can localize this message using following LocalizedString definition:

<LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfIncorrectOTPCodeEntered">Custom message 'UserMessageIfIncorrectOTPCodeEntered'</LocalizedString>

You can find missing strings in the Application Insights traces if you have enabled Application Insights for your RelyingParty definition via JourneyInsights.

Part of the trace which let me find this localization StringId:

{
    "Key": "Exception",
    "Value": {
        "Kind": "Handled",
        "HResult": "80131500",
        "Message": "ErrorCodes: UserMessageIfIncorrectOTPCodeEntered",
        "Data": {
            "IsPolicySpecificError": false
        }
    }
}
maheshbthapa commented 2 years ago

Thank you for the solution help.

SilverioMiranda commented 4 months ago

The ErrorCode UserMessageIfIncorrectOTPCodeEntered was added to the documentation in this PR: https://github.com/MicrosoftDocs/azure-docs/pull/123185.

https://learn.microsoft.com/en-us/azure/active-directory-b2c/localization-string-ids#microsoft-entra-multifactor-authentication-error-messages

image