removeUserWithBiometrics function

Future<Map<String, dynamic>> removeUserWithBiometrics(
  1. String userId
)

Elimina un userId de la lista de usuarios con biometría habilitada.

Implementation

Future<Map<String, dynamic>> removeUserWithBiometrics(String userId) async {
  if (userId.trim().isEmpty) {
    return {
      'success': false,
      'message': 'userId no proporcionado',
      'code': 'BiometricInvalidUserId',
      'error': null,
    };
  }

  try {
    final raw = await _secureStorage.read(key: _biometricUsersKey);
    final List<String> users = raw != null && raw.isNotEmpty
        ? List<String>.from(json.decode(raw) as List)
        : <String>[];

    final updated = users.where((id) => id != userId).toList();
    await _secureStorage.write(
      key: _biometricUsersKey,
      value: json.encode(updated),
      aOptions: const AndroidOptions(encryptedSharedPreferences: true),
    );

    return {
      'success': true,
      'message': 'Usuario eliminado de la lista de biometría',
      'code': 'BiometricUserRemoved',
      'error': null,
    };
  } catch (e) {
    debugPrint('Error en removeUserWithBiometrics: $e');
    return {
      'success': false,
      'message': 'Error al eliminar el usuario con biometría',
      'code': 'BiometricUserRemovalError',
      'error': e.toString(),
    };
  }
}