logout method

Future<ParseResponse> logout({
  1. bool deleteLocalUserData = true,
})

Sends a request to delete the sessions token from the server. Will also delete the local user data unless deleteLocalUserData is false.

Implementation

Future<ParseResponse> logout({bool deleteLocalUserData = true}) async {
  final String? sessionId = ParseCoreData().sessionId;

  if (sessionId == null) {
    return await _handleResponse(
        this,
        ParseNetworkResponse(data: "{}", statusCode: 200),
        ParseApiRQ.logout,
        _debug,
        parseClassName);
  }

  forgetLocalSession();

  if (deleteLocalUserData == true) {
    await this.deleteLocalUserData();
  }

  try {
    final Uri url = getSanitisedUri(_client, keyEndPointLogout);
    final ParseNetworkResponse response = await _client.post(
      url.toString(),
      options: ParseNetworkOptions(
          headers: <String, String>{keyHeaderSessionToken: sessionId}),
    );

    return await _handleResponse(
        this, response, ParseApiRQ.logout, _debug, parseClassName);
  } on Exception catch (e) {
    return handleException(e, ParseApiRQ.logout, _debug, parseClassName);
  }
}