logout method

  1. @override
Future<void> logout()
override

Sends a logout command to the homeserver and clears all local data, including all persistent data from the store.

Implementation

@override
Future<void> logout() async {
  try {
    // Upload keys to make sure all are cached on the next login.
    await encryption?.keyManager.uploadInboundGroupSessions();

    final storedClient = await database.getClient(clientName);
    final oidcClientId = storedClient?.tryGet<String>('oidc_client_id');

    if (oidcClientId == null) {
      // Legacy logout with Matrix spec
      await super.logout();
    } else {
      // Logout with Matrix Native OIDC
      await revokeOidcToken(oidcClientId, accessToken!, 'access_token');
    }
  } catch (e, s) {
    Logs().e('Logout failed', e, s);
    rethrow;
  } finally {
    await clear();
  }
}