Error on unknown dev, format

This commit is contained in:
Jonathan Flueren 2023-08-16 16:53:38 +02:00
parent e5b95ad84a
commit ab31b191a9
3 changed files with 13 additions and 6 deletions

View file

@ -15,7 +15,7 @@ Dependencies:
Configs to change:
- `scanner/scan.sh`:
- WiFi adapter name
- network restart routines
- network restart routines (front-end)
- `scanner/upload.py`:
- URLs for webhook and identities
- webhook secret

View file

@ -71,6 +71,8 @@ function remove_identity($mac)
$hashed_mac = hash_mac($mac);
$url = strtok($_SERVER['REQUEST_URI'], '?');
$identities = json_decode(file_get_contents(IDENTITIES_FILE), true);
$new_identities = array();
@ -84,9 +86,14 @@ function remove_identity($mac)
$_SESSION['form_success'] = true;
$_SESSION['form_success_message'] = 'Identity successfully removed.';
header("Location: " . strtok($_SERVER['REQUEST_URI'], '?'), true, 303);
header("Location: " . $url, true, 303);
exit();
}
$_SESSION['form_success'] = false;
$_SESSION['form_success_message'] = 'Identity not found.';
header("Location: " . $url, true, 303);
exit();
}
if ($_SERVER['REQUEST_METHOD'] == "POST") {

View file

@ -5,7 +5,7 @@ $present_file = 'present.json';
// check for POST request
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
error_log('FAILED - not POST - '. $_SERVER['REQUEST_METHOD']);
error_log('FAILED - not POST - ' . $_SERVER['REQUEST_METHOD']);
http_response_code(405);
exit();
}
@ -14,7 +14,7 @@ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
$content_type = isset($_SERVER['CONTENT_TYPE']) ? strtolower(trim($_SERVER['CONTENT_TYPE'])) : '';
if ($content_type != 'application/json') {
error_log('FAILED - not application/json - '. $content_type);
error_log('FAILED - not application/json - ' . $content_type);
http_response_code(400);
exit();
}
@ -51,7 +51,7 @@ $decoded = json_decode($payload, true);
// check for json decode errors
if (json_last_error() !== JSON_ERROR_NONE) {
error_log('FAILED - json decode - '. json_last_error());
error_log('FAILED - json decode - ' . json_last_error());
http_response_code(400);
exit();
}