79611197

Date: 2025-05-07 18:26:03
Score: 2
Natty:
Report link

I ultimately fixed my issue by using the MsalService.handleRedirectObservable() method and subscribing to the results, then checking for an active account:

this.msal.handleRedirectObservable().subscribe(() => {
  const account = this.msal.instance.getActiveAccount();
  if (account) {
    // do post-login stuff
  } else {
    this.msalBroadcastService.inProgress$.pipe(
      filter(status => status === InteractionStatus.None),
      take(1))
      .subscribe(() => {
        // do post-login stuff
      });
  }
});

If you try to call the getActiveAccount method before the MsalService gets initialized it'll throw an error and it seems like handleRedirectObservable did the initialization I needed to be able to check for an active account, in which case I would either proceed or branch off to do the login logic. There's probably a cleaner way to do this?

Reasons:
  • Blacklisted phrase (0.5): I need
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Self-answer (0.5):
Posted by: Zulukas