isPinStored method

Future<bool> isPinStored(
  1. String username, {
  2. bool testMode = false,
})

Check if PIN is stored

Implementation

Future<bool> isPinStored(String username, {bool testMode = false}) async {
  try {
    OnairosDebugHelper.log('🔍 Checking if PIN is stored');

    // Test mode: Random decision
    if (testMode) {
      final stored = await _storage.retrieveValue('user_pin_stored') == 'true';
      OnairosDebugHelper.log('✅ Test mode: PIN stored = $stored');
      return stored;
    }

    // Check local storage flag
    final locallyStored = await _storage.retrieveValue('user_pin_stored') == 'true';

    // Check if PIN actually exists in secure storage
    final pinExists = await _storage.containsKey('onairos_pin_secure');

    final isStored = locallyStored && pinExists;
    OnairosDebugHelper.log('✅ PIN storage check completed: $isStored');
    return isStored;

  } catch (e) {
    OnairosDebugHelper.log('❌ Error checking PIN storage: $e');
    return false;
  }
}