deleteSession method

Future<void> deleteSession(
  1. String userId
)

Deletes session from Memory, Disk, and Index.

Implementation

Future<void> deleteSession(String userId) async {
  // Memory
  _memorySessions.removeWhere((s) => s.userId == userId);

  // Storage
  await _storage?.delete(key: _userSessionKey(userId));

  // Active Check
  if (_activeSession?.userId == userId) {
    _activeSession = null;
    await _storage?.delete(key: _activeSessionUserIdKey);
    _sessionController.add(null);
  }

  // Index
  await _updateIndex(userId, add: false);
}