From fe913f8135e9df3894b84bcbbaf8fd10e5bd50c2 Mon Sep 17 00:00:00 2001 From: tertek Date: Mon, 26 Feb 2024 08:16:56 +0100 Subject: [PATCH] Minor bug fix #17. --- deviceTracker.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/deviceTracker.php b/deviceTracker.php index 5836b39..0c4e673 100644 --- a/deviceTracker.php +++ b/deviceTracker.php @@ -412,12 +412,18 @@ private function ajax_validateDevice($payload){ return array("validation_message" => "Device is not available."); } - $suspension_date = strtotime(reset($device)["device_suspension_date"]); - if( $suspension_date < time()) { - return array("validation_message" => "Device (ID:".$device_id.") has been suspended: " . reset($device)["device_suspension_date"]); + // Check if suspension date was set and invalidated when suspension time has passed + $suspension_date = reset($device)["device_suspension_date"]; + + if(!empty($suspension_date)){ + $suspension_date_time = strtotime(reset($device)["device_suspension_date"]); + if( $suspension_date_time < time()) { + return array("validation_message" => "Device (ID:".$device_id.") has been suspended: " . $suspension_date); + } } - if(isset($device) && ($suspension_date > time())) { + // return device_id in case the device is valid + if(isset($device)) { return array("device_id" => $device_id); }