1

I'm following a sample for React w/ msal and AADB2C.

I want to run the reset password flow if an user clicks "Forgot my password" in my signIn flow. From here I saw that I need to handle this case:

if (event.eventType === EventType.LOGIN_FAILURE) {
  if (event.error && event.error.errorMessage.indexOf("AADB2C90118") > -1) {
     if (event.interactionType === InteractionType.Redirect) {
       instance.loginRedirect(b2cPolicies.authorities.forgotPassword);
     } else if (event.interactionType === InteractionType.Popup) {
       instance.loginPopup(b2cPolicies.authorities.forgotPassword)
               .catch(e => {
                  return;
                });
     }
  }
}

And the forgotPassword authority is an URL such as https://tenantName.b2clogin.com/tenantName.onmicrosoft.com/B2C_1_PasswordReset for example. Although I'm following these samples and docs, I've run into this issue and there doesn't seem to be any mentions or solutions to this:

Unhandled Rejection (TypeError): Cannot create property 'authenticationScheme' on string 'https://tenantName.b2clogin.com/tenantName.onmicrosoft.com/B2C_1_PasswordReset'

Vivere
  • 1,919
  • 4
  • 16
  • 35

1 Answers1

2

You are getting the error in the console: Unhandled Rejection (TypeError): Cannot create property 'authenticationScheme' on string

You are getting this error because somewhere in your code you are using "authenticationScheme" but at the stage "authenticationScheme" object is null or undefined.

Update your code:

if (authenticationScheme) {
do something here.
}

Once updated if authenticationScheme is null or undefined then it will not execute the code on null or undefined object.

Rutha
  • 751
  • 3
  • 7
  • Hi @Rutha, Im not using authenticationScheme anywhere in the codebase, all Im doing is calling the loginRedirect with password reset policy and Im still getting this issue. Can you help me out? – Ashwin Oct 12 '21 at 12:22
  • Have you tried this on internal server AD? – Rutha Oct 13 '21 at 06:59