Update filtering logic, tokens, and wash certificate handling
Refine db_object_t filtering to handle numeric vs. string values. Add a new token for wash certificate authentication and update routes to include it in responses when applicable. Adjust data type for pickup_bool in bookingsRoute handling.
This commit is contained in:
+2
-1
@@ -21,4 +21,5 @@ if ($DEBUG && !$USE_PROD_ECONOMIC_IN_DEBUG) {
|
||||
'app_secret_token' => '' // Development Economic API secret token
|
||||
];
|
||||
}
|
||||
$WORDPRESS_STATIC_TOKEN = ''; // Static token used to authenticate the WordPress plugin
|
||||
$WORDPRESS_STATIC_TOKEN = ''; // Static token used to authenticate the WordPress plugin
|
||||
$EMAIL_WASH_CERTIFICATE_TOKEN = ''; // Token used to authenticate the wash certificate generator
|
||||
@@ -18,7 +18,9 @@ class bookingsRoute
|
||||
/** All bookings */
|
||||
$this->get('/bookings', function () {
|
||||
// Require the user to be logged in
|
||||
global /** @var response $response */
|
||||
global
|
||||
/** @var response $response */
|
||||
$EMAIL_WASH_CERTIFICATE_TOKEN,
|
||||
$response;
|
||||
$this->requirePermission('list_bookings');
|
||||
// Get the user object
|
||||
@@ -27,6 +29,10 @@ class bookingsRoute
|
||||
if ($user) {
|
||||
// Log the incident
|
||||
(new logs_o())->add('bookings', 'global', 1, $user->id, 'LIST_BOOKINGS', 'Successfully listed bookings');
|
||||
// If the user has the permission to issue wash certificates, add the wash certificate key to the response
|
||||
if ($user->hasPermission('issue_wash_certificates')) {
|
||||
$response->add_meta('wash_certificate_token', $EMAIL_WASH_CERTIFICATE_TOKEN);
|
||||
}
|
||||
// Return the list of bookings
|
||||
$response->success(
|
||||
(new bookings_o())->listObjectsWithPaginationIfSet()
|
||||
@@ -103,7 +109,7 @@ class bookingsRoute
|
||||
(string)$booking['washCertificateEmail'],
|
||||
(string)$booking['date'],
|
||||
(string)$booking['department'],
|
||||
(bool)$booking['pickup_bool'],
|
||||
(string)$booking['pickup_bool'],
|
||||
(string)$booking['notes'],
|
||||
(string)$booking['washCertificateStatus'],
|
||||
(string)$booking['washCertificateUrl'],
|
||||
|
||||
@@ -123,7 +123,12 @@ trait db_object_t
|
||||
$searchQuery = 'WHERE ';
|
||||
}
|
||||
foreach ( $filters as $field => $value ) {
|
||||
$searchQuery .= "$field = $value AND ";
|
||||
// If the value is a number, do not add quotes
|
||||
if (is_numeric($value)) {
|
||||
$searchQuery .= "$field = $value AND ";
|
||||
} else {
|
||||
$searchQuery .= "$field = '$value' AND ";
|
||||
}
|
||||
}
|
||||
// If the deleted_at column exists, filter out the deleted objects
|
||||
if (in_array('deleted_at', $searchfields)) {
|
||||
|
||||
Reference in New Issue
Block a user