storeRedirectHash static method

void storeRedirectHash()

Handles the state hash parameter returned from the authentication provider if B2CInteractionMode.REDIRECT mode is selected. This method should be called before the MaterialApp widget overwrites the url.

See also:

Implementation

static void storeRedirectHash() {
  _lastHash = window.location.hash;
  if (_lastHash == "#/") {
    bool interactionWasStarted = false;
    window.sessionStorage.forEach((key, value) {
      //this happens when user click back button on redirect hash
      if (key.startsWith("msal") && value == "interaction_in_progress") {
        interactionWasStarted = true;
      }
    });

    if (interactionWasStarted) {
      log("User pressed back button, cleaning", name: "B2CProviderWebStatic");
      window.sessionStorage
          .removeWhere((key, value) => key.startsWith("msal"));
    }
  }

  log(_lastHash!, name: "B2CProviderWebStatic");
}