<?php
  function authenticate($conn, $device_name, $password) {
    $sql = $conn->prepare("SELECT * FROM devices WHERE name = ?");
    $sql = $conn->bind_param("s", $device_name);
    $sql->execute();
    $device = $sql->get_result()->fetch_assoc();
    if ($device["approved"] && password_verify($password, $device["hash"])) {
      return true;
    } else {
      return false;
    }
  }
?>

<?php
  function authenticate($conn, $device_name, $password) {
    $sql = $conn->prepare("SELECT * FROM devices WHERE name = ?");
    $sql = $conn->bind_param("s", $device_name);
    $sql->execute();
    $result = $sql->get_result();
    if ($result->num_rows == 1) {
      $device = $result->fetch_assoc();
      if ($device["approved"] && password_verify($password, $device["hash"])) {
        return true;
      } else {
        return false;
      }
    } else {
      return false;
    }
  }
?>

Make sure that there is only 1 such device
Make sure that there is only 1 such device
