signOut method

Future signOut(
  1. String tag,
  2. String subject
)

Sign out user and erases associated tokens.

The tag argument is used to distinguish which invocation of this function generated the return callback. The subject is used to specify the user to authenticate (it corresponds to the

Returns a Future callable from the AzureB2C plugin.

It emits a B2COperationResult from B2COperationSource.SIGN_OUT with possible results:

Implementation

Future signOut(String tag, String subject) async {
  try {
    var user = _users[subject];
    if (user == null) {
      _emitCallback(B2COperationResult(
          tag,
          B2COperationSource.POLICY_TRIGGER_SILENTLY,
          B2COperationState.CLIENT_ERROR));
      return;
    }

    if (_interactionMode == B2CInteractionMode.REDIRECT) {
      await _b2cApp!.logoutRedirect(EndSessionRequest()..account = user);
      return; //redirect flow will restart the app
    } else {
      await _b2cApp!.logoutPopup(EndSessionPopupRequest()..account = user);

      _users.remove(_getUniqueId(user));
      _emitCallback(B2COperationResult(
          tag, B2COperationSource.SIGN_OUT, B2COperationState.SUCCESS));
    }
  } on AuthException {
    _emitCallback(B2COperationResult(
        tag, B2COperationSource.SIGN_OUT, B2COperationState.CLIENT_ERROR));
  }
}