fixed raspberry authentication for getConfig and removed IP verifiing

This commit is contained in:
2024-02-19 12:51:34 +01:00
parent 36b3f1e0f8
commit 58dbd749f8
2 changed files with 4 additions and 5 deletions
@@ -60,10 +60,9 @@ class RaspberryDisplayController extends mfBaseController
} }
protected function getConfig() { protected function getConfig() {
$ip = $_SERVER['REMOTE_ADDR'];
$hostname = $this->request->hostname; $hostname = $this->request->hostname;
$displays = RaspberryDisplayModel::getByHostnameAndIp($hostname, $ip); $displays = RaspberryDisplayModel::getByHostname($hostname);
if ($displays === null) { if ($displays === null) {
die("No display found for this hostname and ip:" . $hostname . " X " . $ip); die("No display found for this hostname and ip:" . $hostname . " X " . $ip);
@@ -82,7 +81,7 @@ class RaspberryDisplayController extends mfBaseController
protected function apiAction() { protected function apiAction() {
$do = $this->request->do; $do = $this->request->do;
if (!$this->me->is("employee") && !in_array($do, ["getDisplays", "change", "reboot"])) { if ($do !== "getConfig" && !$this->me->is("employee")) {
$this->redirect("dashboard"); $this->redirect("dashboard");
} }
@@ -29,11 +29,11 @@ class RaspberryDisplayModel
return null; return null;
} }
public static function getByHostnameAndIp($hostname, $ip) public static function getByHostname($hostname)
{ {
$db = FronkDB::singleton(); $db = FronkDB::singleton();
$res = $db->select("RaspberryDisplay", "*", "hostname = '$hostname' AND ip_address = '$ip'"); $res = $db->select("RaspberryDisplay", "*", "hostname = '$hostname'");
//fetch 2 rows //fetch 2 rows
if ($db->num_rows($res)) { if ($db->num_rows($res)) {