Microsoft-authentication-library-for-js: [Help needed] How to implement forgot password flow?

Created on 27 Jan 2020  路  14Comments  路  Source: AzureAD/microsoft-authentication-library-for-js

Please follow the issue template below. Failure to do so will result in a delay in answering your question.

Library

Description

I'm trying to implement the 'Reset Password' or 'Forgot Password' flow but the msal user agent doesn't seem to expose any methods for this. How should I be handling the 'Forgot Password' click on the sign_in B2C policy?

b2c question

Most helpful comment

Our b2c sample has been updated to show how to implement the forgot password flow and can be found here

All 14 comments

@gopinav Sorry for the inconvenience. We are working on making the B2C experience in our library smoother, I will update here when I have more info.

Three years to get this functionality??? Really

Sorry for the inconvenience. We are working on making the B2C experience in our library smoother, I will update here when I have more info.

Any updates on this? it's impossible to put an application into production without this functionality.

In previous versions it was possible to replace the authority with the url to the password forgot policy and just call the loginredirect or loginpopup method.

I鈥檓 currently on the latest beta version that鈥檚 on npm and this method doesn鈥檛 work anymore.

I got it to work with beta version.

Used package versions:

"@azure/msal-angular": "^1.0.0-beta.3",
"msal": "^1.2.2-beta.1",
this.ms.handleRedirectCallback((authError, response) => {
  // get msal error from storage
  const msalErrorDescription = localStorage.getItem(
    "msal.error.description"
  );
  // check if msal error set
  if (msalErrorDescription) {
    // check if error code for forgot password is there
    if (msalErrorDescription.indexOf("AADB2C90118") > -1) {
      // change authority to password reset policy
      this.ms.loginRedirect({
        authority: environment.passwordResetPolicy
      });
      return;
    }
  }
});

'environment.passwordResetPolicy' is an url to the password reset policy like: 'https://{tenant}.b2clogin.com/{tenant}.onmicrosoft.com/B2C_1A_ChangePassword'

This seems to work in development env, but not when I publish it to Azure app service.
Any devs know why?

This seems to work in development env, but not when I publish it to Azure app service.
Any devs know why?

I'm running some tests today to see if I can make it work.

It has something to do with executing the redirect in the handleRedirectCallback.
If I move the loginRedirect to the passwordResetPolicy outside the handleRedirectCallback it does work.

It has something to do with executing the redirect in the handleRedirectCallback.
If I move the loginRedirect to the passwordResetPolicy outside the handleRedirectCallback it does work.

During the weekend I made some tests and finally I have it working in my project, during the day I will upload an example repo.

Great! I鈥檒l take a look when it鈥檚 there.

Great! I鈥檒l take a look when it鈥檚 there.

https://github.com/jeverduzco/msal-nuxt-example

In this repo I have an example working, the msal settings are in msal/msal.js and the logic to capture the error of recovering password is in pages/auth.vue

Can't get it to run but see what you did. Thanks!

Our b2c sample has been updated to show how to implement the forgot password flow and can be found here

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spottedmahn picture spottedmahn  路  3Comments

exequeryphil picture exequeryphil  路  3Comments

adriannasui picture adriannasui  路  3Comments

ed-ilyin picture ed-ilyin  路  4Comments

sameerag picture sameerag  路  3Comments