endSession method

Future<SecurityResult<void>> endSession({
  1. bool clearTokens = true,
})

Ends the session explicitly (logout). Does not emit onSessionExpired. With clearTokens the stored tokens and expiry are removed; the first failure of that cleanup is returned.

Implementation

Future<SecurityResult<void>> endSession({bool clearTokens = true}) async {
  final wasActive = _active;
  _stop();
  if (wasActive) SecurityLogger.info('Session ended');
  if (!clearTokens) return const Success(null);
  return _clearTokens();
}