Merge branch 'bugfix/raspberrydisplay-auth-fix' into 'master'

Bugfix/raspberrydisplay auth fix

See merge request fronk/thetool!252
This commit is contained in:
Frank Schubert
2024-02-19 11:55:20 +00:00
2 changed files with 5 additions and 6 deletions

View File

@@ -60,13 +60,12 @@ class RaspberryDisplayController extends mfBaseController
}
protected function getConfig() {
$ip = $_SERVER['REMOTE_ADDR'];
$hostname = $this->request->hostname;
$displays = RaspberryDisplayModel::getByHostnameAndIp($hostname, $ip);
$displays = RaspberryDisplayModel::getByHostname($hostname);
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 ");
}
return array_map(function ($display) {
@@ -82,7 +81,7 @@ class RaspberryDisplayController extends mfBaseController
protected function apiAction() {
$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");
}

View File

@@ -29,11 +29,11 @@ class RaspberryDisplayModel
return null;
}
public static function getByHostnameAndIp($hostname, $ip)
public static function getByHostname($hostname)
{
$db = FronkDB::singleton();
$res = $db->select("RaspberryDisplay", "*", "hostname = '$hostname' AND ip_address = '$ip'");
$res = $db->select("RaspberryDisplay", "*", "hostname = '$hostname'");
//fetch 2 rows
if ($db->num_rows($res)) {