update entra id

This commit is contained in:
2025-05-13 15:03:09 +02:00
parent 6752d3515f
commit 2a96d24de7
44 changed files with 3835 additions and 1856 deletions
+9 -70
View File
@@ -23,73 +23,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// If the JSON is valid
if (json_last_error() === JSON_ERROR_NONE) {
// Authenticate using key, secret_key, and reflab
if (!isset($decoded_data['key']) || !isset($decoded_data['secret_key']) || !isset($decoded_data['reflab'])) {
echo json_encode([
"status" => "error",
"message" => "Missing authentication fields (key, secret_key, reflab)."
]);
exit;
}
$api_key = $decoded_data['key'];
$secret_key = $decoded_data['secret_key'];
$reflab = $decoded_data['reflab'];
$query = "SELECT * FROM laboratories WHERE reflab = ? AND api_key = ?";
$stmt = $conn->prepare($query);
$stmt->bind_param("ss", $reflab, $api_key);
$stmt->execute();
$result = $stmt->get_result();
// Check if a valid laboratory was found with `reflab` and `api_key`
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
// Verify the status of the laboratory
if ($row['status'] !== 'active') {
echo json_encode([
"status" => "error",
"message" => "Laboratory is inactive."
]);
exit;
}
// Verify the secret key using `password_verify`
if (!password_verify($secret_key, $row['api_secret'])) {
echo json_encode([
"status" => "error",
"message" => "Invalid secret key."
]);
exit;
}
} else {
// Check if the `reflab` is valid, but the `api_key` doesn't match
$query = "SELECT * FROM laboratories WHERE reflab = ?";
$stmt = $conn->prepare($query);
$stmt->bind_param("s", $reflab);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
echo json_encode([
"status" => "error",
"message" => "Invalid API key."
]);
} else {
echo json_encode([
"status" => "error",
"message" => "Invalid reflab."
]);
}
exit;
}
// Generate a UUID to uniquely identify the record
$uuid = uniqid(); // Alternatively, use UUID() in MySQL
// Extract some information from JSON
if (!isset($decoded_data['product']['products_refnumber'])) {
// Check only for the required product_refnumber
if (!isset($decoded_data['product']) || !is_array($decoded_data['product']) || !isset($decoded_data['product'][0]['products_refnumber'])) {
echo json_encode([
"status" => "error",
"message" => "Missing product reference number."
@@ -97,9 +32,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
exit;
}
$product_refnumber = $decoded_data['product']['products_refnumber']; // Product number
$report_number = $decoded_data['product']['reports'][0]['reportsNumberLab'] ?? null; // Report number
$rating = $decoded_data['product']['reports'][0]['reportsRating'] ?? null; // Report rating (e.g., Pass/Fail)
// Generate a UUID to uniquely identify the record
$uuid = uniqid(); // Alternatively, use UUID() in MySQL
// Extract some information from JSON
$product_refnumber = $decoded_data['product'][0]['products_refnumber'];
$report_number = $decoded_data['product'][0]['reports'][0]['reportsNumberLab'] ?? null;
$rating = $decoded_data['product'][0]['reports'][0]['reportsRating'] ?? null;
$saved_at = date("Y-m-d H:i:s"); // Save date
// Query to insert data into the temp_json_queue table