tokenExpired method

  1. @override
Future<bool> tokenExpired()
override

Checks if the current user's authentication token is expired.

Implementation

@override
Future<bool> tokenExpired() async {
  if (!_isAuthenticated) return true;
  try {
    // Check token validity by making a lightweight, authenticated API call.
    // A successful call means the token is valid.
    final _ = await _executeRequest(
      () => client.listFiles(
        '/',
        isAppFolder:
            MultiCloudStorage.cloudAccess == CloudAccessType.appStorage,
      ),
      operation: 'tokenExpiredCheck',
    );
    return false; // Success means token is not expired.
  } catch (e) {
    // Any exception here implies the token is invalid or expired.
    // The error is already logged by _executeRequest.
    return true;
  }
}