deleteAllSessions method

Future<void> deleteAllSessions(
  1. DeactivateSessionsRequest request
)

Implementation

Future<void> deleteAllSessions(DeactivateSessionsRequest request) async {
  _ensureInitialised();

  if (_useMockData) {
    await Future.delayed(const Duration(milliseconds: 300));
    return;
  }

  try {
    final client = await _createClientWithAuthHeaders();
    final response = await client.post(
      url:
          '$_sessionServiceUrl/userSession/api/session/DeactivateUserSessions',
      requestData: request.toJson(),
      user: _user,
    );

    if (response?.statusCode != 200) {
      throw AuthException(
        AuthenticationErrorCodes.allSessionDeletionFailed,
        cause: response?.data,
      );
    }
  } catch (e, s) {
    logger.error(
      this,
      'Exception while deleting all sessions',
      error: e,
      stackTrace: s,
    );
    rethrow;
  }
}