deleteSession method

  1. @override
Future<void> deleteSession({
  1. SessionId? id,
  2. UserPassword? password,
  3. DeviceToken? token,
  4. AccessTokenSecret? accessToken,
})
override

Invalidates a Session with the provided id of the MyUser identified by the accessToken, if any, or otherwise Session of the MyUser identified by the token.

Unregisters a device (Android, iOS, or Web) from receiving notifications via Firebase Cloud Messaging, if token is provided.

Implementation

@override
Future<void> deleteSession({
  SessionId? id,
  UserPassword? password,
  DeviceToken? token,
  AccessTokenSecret? accessToken,
}) async {
  Log.debug(
    'deleteSession(id: $id, password: ${password?.obscured}, token: $token, accessToken: $accessToken)',
    '$runtimeType',
  );

  if (token != null) {
    await Future.wait([
      if (token.fcm != null)
        _graphQlProvider.unregisterPushDevice(
          PushDeviceToken(fcm: token.fcm),
        ),
      if (token.apns != null)
        _graphQlProvider.unregisterPushDevice(
          PushDeviceToken(apns: token.apns),
        ),
      if (token.voip != null)
        _graphQlProvider.unregisterPushDevice(
          PushDeviceToken(apnsVoip: token.voip),
        ),
    ]);
  }

  await _graphQlProvider.deleteSession(
    id: id,
    confirmation: password == null
        ? null
        : MyUserCredentials(password: password),
    token: accessToken,
  );
}