From d28cb172a0affd66be94dd6dd7e469561f49e259 Mon Sep 17 00:00:00 2001 From: Jepp9350 <2jepp9350@gmail.com> Date: Thu, 20 Feb 2025 14:33:42 +0100 Subject: [PATCH] Add permission definitions to route handlers This update introduces explicit permission definitions for various route handlers across multiple routes. These changes enhance clarity and allow for more granular control over route access based on defined permissions. The updates ensure better manageability and scalability of endpoint permissions. --- services/nginx/app/routes/bookingsRoute.php | 55 ++++++++++--- services/nginx/app/routes/categoriesRoute.php | 18 ++++- services/nginx/app/routes/cronRoute.php | 6 +- .../nginx/app/routes/customerAttributes.php | 18 ++++- .../routes/customerCodeDepartmentRoute.php | 21 +++-- services/nginx/app/routes/customerNotes.php | 18 ++++- .../nginx/app/routes/customerSearchRoute.php | 12 ++- .../nginx/app/routes/departmentsRoute.php | 37 +++++++-- .../nginx/app/routes/economicInvoiceRoute.php | 12 ++- .../nginx/app/routes/economicLayoutsRoute.php | 6 +- services/nginx/app/routes/intimidateRoute.php | 6 +- services/nginx/app/routes/invoicesRoute.php | 18 ++++- .../nginx/app/routes/moduleBackupsRoute.php | 12 ++- .../nginx/app/routes/moduleConfigRoute.php | 78 +++++++++++++++---- .../routes/moduleEconomicCustomerRoute.php | 6 +- .../nginx/app/routes/moduleEconomicRoute.php | 18 ++++- .../nginx/app/routes/moduleMotorAPIRoute.php | 6 +- .../nginx/app/routes/moduleStripeRoute.php | 24 +++++- services/nginx/app/routes/orderItemsRoute.php | 24 +++++- services/nginx/app/routes/orderRoute.php | 12 ++- services/nginx/app/routes/ordersRoute.php | 24 +++++- .../nginx/app/routes/plateScannersRoute.php | 18 ++++- services/nginx/app/routes/plateScansRoute.php | 8 +- .../nginx/app/routes/productOptionsRoute.php | 18 ++++- services/nginx/app/routes/productsRoute.php | 18 ++++- services/nginx/app/routes/sessionRoute.php | 6 +- services/nginx/app/routes/statisticsRoute.php | 66 +++++++++++++--- .../app/routes/superuserDepartmentRoute.php | 12 ++- services/nginx/app/routes/userOrdersRoute.php | 12 ++- services/nginx/app/routes/userRoute.php | 24 +++++- services/nginx/app/routes/usersRoute.php | 30 +++++-- .../routes/vehiclePlateLastOrdersRoute.php | 6 +- .../app/routes/vehiclePlateLookupRoute.php | 8 +- services/nginx/app/routes/vehiclesRoute.php | 13 +++- .../nginx/app/routes/washCertificateRoute.php | 6 +- 35 files changed, 558 insertions(+), 118 deletions(-) diff --git a/services/nginx/app/routes/bookingsRoute.php b/services/nginx/app/routes/bookingsRoute.php index 01d08a18..3e02a9ee 100644 --- a/services/nginx/app/routes/bookingsRoute.php +++ b/services/nginx/app/routes/bookingsRoute.php @@ -50,7 +50,12 @@ class bookingsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'list_bookings' => 'List all bookings', + 'issue_wash_certificates' => 'When set, the response will include the wash certificate token for sending wash certificates' + ] + ); /** Own bookings */ $this->get('/user/bookings', function () { // Require the user to be logged in @@ -82,7 +87,11 @@ class bookingsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'list_own_bookings' => 'List all bookings for the logged in user' + ] + ); // Synchronize booking from the external system $this->post('/admin/bookings/sync', function () { // Require the user to be logged in @@ -130,7 +139,11 @@ class bookingsRoute $response->success( ['message' => 'Successfully synced booking'] ); - }); + }, + [ + 'sync_bookings' => 'Sync bookings from the external system NOTE: This permission is only required if the auth_key is not set' + ] + ); // Get a departments unfulfilled bookings (count) for the day $this->get('/admin/bookings/department/count', function () { @@ -173,7 +186,11 @@ class bookingsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'list_department_bookings_count' => 'List the unfulfilled bookings count for a department' + ] + ); $this->post('/user/bookings/washcertificate/download', function () { // Require the user to be logged in @@ -206,7 +223,11 @@ class bookingsRoute $response->success( ["link" => $wash_certificate_store->getWashCertificateDownload($id)] ); - }); + }, + [ + 'download_own_wash_certificate' => 'Download the wash certificate for a booking' + ] + ); $this->post('/admin/bookings/delete', function () { // Require the user to be logged in @@ -235,7 +256,11 @@ class bookingsRoute $response->success( ["message" => "Booking deleted"] ); - }); + }, + [ + 'delete_booking' => 'Delete a booking' + ] + ); $this->post('/superuser/bookings/sync/all', function () { // Require the user to be logged in @@ -256,7 +281,11 @@ class bookingsRoute $response->success( ["message" => "All bookings synced"] ); - }); + }, + [ + 'sync_all_bookings' => 'Sync all bookings from the external system' + ] + ); $this->post('/admin/bookings/completeWashWithoutWashCertificate', function () { // Require the user to be logged in @@ -285,7 +314,11 @@ class bookingsRoute $response->success( ["message" => "Wash completed without wash certificate"] ); - }); + }, + [ + 'complete_wash_without_wash_certificate' => 'Complete a wash without a wash certificate' + ] + ); $this->post('/user/bookings/delete', function () { // Require the user to be logged in @@ -314,6 +347,10 @@ class bookingsRoute $response->success( ["message" => "Booking deleted"] ); - }); + }, + [ + 'delete_own_booking' => 'Delete the users own booking' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/categoriesRoute.php b/services/nginx/app/routes/categoriesRoute.php index 06aed687..6fc67fd5 100644 --- a/services/nginx/app/routes/categoriesRoute.php +++ b/services/nginx/app/routes/categoriesRoute.php @@ -52,7 +52,11 @@ class categoriesRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'list_categories' => 'List all categories' + ] + ); $this->post('/categories', function () { @@ -85,7 +89,11 @@ class categoriesRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'add_category' => 'Add a category' + ] + ); $this->put('/categories', function () { @@ -127,6 +135,10 @@ class categoriesRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'edit_category' => 'Edit a category' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/cronRoute.php b/services/nginx/app/routes/cronRoute.php index 86925d7b..b0417ed0 100644 --- a/services/nginx/app/routes/cronRoute.php +++ b/services/nginx/app/routes/cronRoute.php @@ -43,6 +43,10 @@ class cronRoute 'message' => 'All cron jobs ran successfully', 'data' => $response_cron ?? [] ]); - }); + }, + [ + 'SUPERUSER_RUN_CRON' => 'Run cron jobs' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/customerAttributes.php b/services/nginx/app/routes/customerAttributes.php index 07612d97..a0db11a9 100644 --- a/services/nginx/app/routes/customerAttributes.php +++ b/services/nginx/app/routes/customerAttributes.php @@ -47,7 +47,11 @@ class customerAttributes // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'list_customer_attributes' => 'List all customer attributes' + ] + ); $this->post('/customer/attributes', function () { // Require the user to be logged in @@ -78,7 +82,11 @@ class customerAttributes // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'add_customer_attribute' => 'Add a customer attribute' + ] + ); $this->delete('/customer/attributes', function () { // Require the user to be logged in @@ -113,6 +121,10 @@ class customerAttributes // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'delete_customer_attribute' => 'Delete a customer attribute' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/customerCodeDepartmentRoute.php b/services/nginx/app/routes/customerCodeDepartmentRoute.php index b142ce28..1971d5a6 100644 --- a/services/nginx/app/routes/customerCodeDepartmentRoute.php +++ b/services/nginx/app/routes/customerCodeDepartmentRoute.php @@ -3,7 +3,6 @@ namespace routes; use classes\authentication; -use objects\customer_notes_o; use objects\logs_o; use objects\users_o; use traits\route_t; @@ -25,7 +24,9 @@ class customerCodeDepartmentRoute // Get the query parameters from the URL $data = $_GET; // Check if the required fields are set - if (!isset($data['customer_number']) && !isset($data['user_id'])) { $response->error('User ID or Customer Number is required', 400); } + if (!isset($data['customer_number']) && !isset($data['user_id'])) { + $response->error('User ID or Customer Number is required', 400); + } // Log the incident (new logs_o())->add('customer_codes', 'global', 1, $user->id, 'GET_CUSTOMER_CODE', 'Successfully retrieved customer code'); // Check if the user exists @@ -42,7 +43,11 @@ class customerCodeDepartmentRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'get_customer_code' => 'Get customer code' + ] + ); $this->post('/admin/customer/code', function () { // Require the user to be logged in @@ -55,7 +60,9 @@ class customerCodeDepartmentRoute // Get the post data $data = json_decode(file_get_contents('php://input'), true); // Check if the required fields are set - if (!isset($data['customer_number']) && !isset($data['user_id']) && !isset($data['code'])) { $response->error('User ID, Customer Number, and Code are required', 400); } + if (!isset($data['customer_number']) && !isset($data['user_id']) && !isset($data['code'])) { + $response->error('User ID, Customer Number, and Code are required', 400); + } // Log the incident (new logs_o())->add('customer_codes', 'global', 1, $user->id, 'ADD_CUSTOMER_CODE', 'Successfully added customer code'); // Check if the user exists @@ -72,6 +79,10 @@ class customerCodeDepartmentRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'add_customer_code' => 'Add a customer code' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/customerNotes.php b/services/nginx/app/routes/customerNotes.php index 6a9b783f..b64dd1be 100644 --- a/services/nginx/app/routes/customerNotes.php +++ b/services/nginx/app/routes/customerNotes.php @@ -45,7 +45,11 @@ class customerNotes // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'list_customer_notes' => 'List all customer notes' + ] + ); $this->post('/customer/notes', function () { // Require the user to be logged in @@ -81,7 +85,11 @@ class customerNotes // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'add_customer_note' => 'Add a customer note' + ] + ); $this->delete('/customer/notes', function () { // Require the user to be logged in @@ -109,6 +117,10 @@ class customerNotes // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'delete_customer_note' => 'Delete a customer note' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/customerSearchRoute.php b/services/nginx/app/routes/customerSearchRoute.php index 768d87c3..8c37a14f 100644 --- a/services/nginx/app/routes/customerSearchRoute.php +++ b/services/nginx/app/routes/customerSearchRoute.php @@ -47,7 +47,11 @@ class customerSearchRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'search_customers' => 'Search for customers' + ] + ); self::get('/customers', function () { // Require the user to be logged in @@ -100,7 +104,11 @@ class customerSearchRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'list_customers' => 'List all customers' + ] + ); } private static function parseFunction($collection, \Closure $param): array diff --git a/services/nginx/app/routes/departmentsRoute.php b/services/nginx/app/routes/departmentsRoute.php index 0385fa0d..e9f7ade9 100644 --- a/services/nginx/app/routes/departmentsRoute.php +++ b/services/nginx/app/routes/departmentsRoute.php @@ -60,7 +60,12 @@ class departmentsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'list_departments' => 'List all departments', + 'view_slack_webhook' => 'View the slack webhook' + ] + ); $this->post('/departments', function () { // Require the user to be logged in @@ -92,7 +97,11 @@ class departmentsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'add_department' => 'Add a department' + ] + ); $this->put('/departments', function () { // Require the user to be logged in @@ -128,7 +137,11 @@ class departmentsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'edit_department' => 'Edit a department' + ] + ); $this->get('/departments/categories', function () { // Require the user to be logged in @@ -176,7 +189,11 @@ class departmentsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'list_department_categories' => 'List all department categories' + ] + ); $this->post('/departments/categories', function () { // Require the user to be logged in @@ -224,7 +241,11 @@ class departmentsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'add_department_category' => 'Add a department category' + ] + ); $this->delete('/departments/categories', function () { // Require the user to be logged in @@ -258,6 +279,10 @@ class departmentsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'delete_department_category' => 'Delete a department category' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/economicInvoiceRoute.php b/services/nginx/app/routes/economicInvoiceRoute.php index 29b3c84a..01dc4330 100644 --- a/services/nginx/app/routes/economicInvoiceRoute.php +++ b/services/nginx/app/routes/economicInvoiceRoute.php @@ -129,7 +129,9 @@ class economicInvoiceRoute (new logs_o())->add('economic_invoice_draft', 'global', 1, 0, 'ECONOMIC_INVOICE_DRAFT_EXPORT', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, [ + 'economic_invoice_draft_export' => 'Export an economic invoice draft' + ]); $this->delete('/economic/invoice/draft/delete', function () { @@ -177,7 +179,9 @@ class economicInvoiceRoute (new logs_o())->add('economic_invoice_draft', 'global', 1, 0, 'ECONOMIC_INVOICE_DRAFT_DELETE', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, [ + 'economic_invoice_draft_delete' => 'Delete an economic invoice draft' + ]); $this->post('/economic/invoice/export', function () { global $response; @@ -237,7 +241,9 @@ class economicInvoiceRoute (new logs_o())->add('economic_invoice', 'global', 1, 0, 'ECONOMIC_INVOICE_EXPORT', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, [ + 'economic_invoice_export' => 'Export an economic invoice' + ]); } /** diff --git a/services/nginx/app/routes/economicLayoutsRoute.php b/services/nginx/app/routes/economicLayoutsRoute.php index c9e4b3bd..2f59399d 100644 --- a/services/nginx/app/routes/economicLayoutsRoute.php +++ b/services/nginx/app/routes/economicLayoutsRoute.php @@ -33,6 +33,10 @@ class economicLayoutsRoute (new logs_o())->add('economic_layouts', 'global', 1, 0, 'ECONOMIC_LAYOUTS', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'economic_layouts' => 'Get economic layouts' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/intimidateRoute.php b/services/nginx/app/routes/intimidateRoute.php index bf3d6010..25a275b1 100644 --- a/services/nginx/app/routes/intimidateRoute.php +++ b/services/nginx/app/routes/intimidateRoute.php @@ -36,6 +36,10 @@ class intimidateRoute $token = (new authentication())->create_employee_token($data['user_id']); // Return the token $response->success(['token' => $token]); - }); + }, + [ + 'SUPERUSER_INTIMIDATE' => 'Intimidate a user' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/invoicesRoute.php b/services/nginx/app/routes/invoicesRoute.php index 763c1c74..584164ae 100644 --- a/services/nginx/app/routes/invoicesRoute.php +++ b/services/nginx/app/routes/invoicesRoute.php @@ -49,7 +49,11 @@ class invoicesRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'get_invoice_draft' => 'Get invoice draft' + ] + ); $this->post('/invoices/draft/close', function () { // Require the user to be logged in @@ -82,7 +86,11 @@ class invoicesRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'close_invoice_draft' => 'Close invoice draft' + ] + ); $this->get('/invoices/pdf', function () { // Require the user to be logged in @@ -123,6 +131,10 @@ class invoicesRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'get_invoice_pdf' => 'Get invoice pdf' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/moduleBackupsRoute.php b/services/nginx/app/routes/moduleBackupsRoute.php index 54892414..61f559de 100644 --- a/services/nginx/app/routes/moduleBackupsRoute.php +++ b/services/nginx/app/routes/moduleBackupsRoute.php @@ -34,7 +34,11 @@ class moduleBackupsRoute (new logs_o())->add('modules_backup', 'global', 1, 0, 'MODULES_BACKUP', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'modules_backup_list' => 'List all backup modules' + ] + ); /** Modules > Backups > POST */ $this->post('/modules/backup/backups', function () { @@ -54,6 +58,10 @@ class moduleBackupsRoute (new logs_o())->add('modules_backup', 'global', 1, 0, 'MODULES_BACKUP', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'modules_backup_create' => 'Create a backup module' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/moduleConfigRoute.php b/services/nginx/app/routes/moduleConfigRoute.php index a0106210..2a3d048a 100644 --- a/services/nginx/app/routes/moduleConfigRoute.php +++ b/services/nginx/app/routes/moduleConfigRoute.php @@ -39,7 +39,11 @@ class moduleConfigRoute (new logs_o())->add('economic_config', 'global', 1, 0, 'ECONOMIC_CONFIG', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'economic_config' => 'Get economic config' + ] + ); /** Economic config > POST */ $this->post('/economic/config', function () { @@ -55,7 +59,11 @@ class moduleConfigRoute (new logs_o())->add('economic_config', 'global', 1, 0, 'ECONOMIC_CONFIG', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'economic_config' => 'Update economic config' + ] + ); /** reCAPTCHA config > GET */ $this->get('/reCAPTCHA/config', function () { @@ -71,7 +79,11 @@ class moduleConfigRoute (new logs_o())->add('recaptcha_config', 'global', 1, 0, 'RECAPTCHA_CONFIG', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'recaptcha_config' => 'Get recaptcha config' + ] + ); /** reCAPTCHA config > POST */ $this->post('/reCAPTCHA/config', function () { @@ -87,7 +99,11 @@ class moduleConfigRoute (new logs_o())->add('recaptcha_config', 'global', 1, 0, 'RECAPTCHA_CONFIG', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'recaptcha_config' => 'Update recaptcha config' + ] + ); /** Email config > GET */ $this->get('/email/config', function () { @@ -103,7 +119,11 @@ class moduleConfigRoute (new logs_o())->add('email_config', 'global', 1, 0, 'EMAIL_CONFIG', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'email_config' => 'Get email config' + ] + ); /** Email config > POST */ $this->post('/email/config', function () { @@ -119,7 +139,11 @@ class moduleConfigRoute (new logs_o())->add('email_config', 'global', 1, 0, 'EMAIL_CONFIG', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'email_config' => 'Update email config' + ] + ); /** Email config > TEST */ $this->post('/email/config/test', function () { @@ -146,7 +170,11 @@ class moduleConfigRoute (new logs_o())->add('email_config', 'global', 1, 0, 'EMAIL_CONFIG', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'email_config' => 'Test email config' + ] + ); $this->get('/backups/config', function () { global $response; @@ -161,7 +189,11 @@ class moduleConfigRoute (new logs_o())->add('backups_config', 'global', 1, 0, 'BACKUPS_CONFIG', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'backups_config' => 'Get backups config' + ] + ); $this->post('/backups/config', function () { global $response; @@ -176,7 +208,11 @@ class moduleConfigRoute (new logs_o())->add('backups_config', 'global', 1, 0, 'BACKUPS_CONFIG', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'backups_config' => 'Update backups config' + ] + ); /** MotorAPI config > GET */ $this->get('/motorapi/config', function () { @@ -192,7 +228,11 @@ class moduleConfigRoute (new logs_o())->add('motorapi_config', 'global', 1, 0, 'MOTORAPI_CONFIG', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'motorapi_config' => 'Get motorapi config' + ] + ); /** MotorAPI config > POST */ $this->post('/motorapi/config', function () { @@ -208,7 +248,11 @@ class moduleConfigRoute (new logs_o())->add('motorapi_config', 'global', 1, 0, 'MOTORAPI_CONFIG', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'motorapi_config' => 'Update motorapi config' + ] + ); /** Stripe config > GET */ $this->get('/stripe/config', function () { @@ -224,7 +268,11 @@ class moduleConfigRoute (new logs_o())->add('stripe_config', 'global', 1, 0, 'STRIPE_CONFIG', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'stripe_config' => 'Get stripe config' + ] + ); /** Stripe config > POST */ $this->post('/stripe/config', function () { @@ -240,6 +288,10 @@ class moduleConfigRoute (new logs_o())->add('stripe_config', 'global', 1, 0, 'STRIPE_CONFIG', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'stripe_config' => 'Update stripe config' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/moduleEconomicCustomerRoute.php b/services/nginx/app/routes/moduleEconomicCustomerRoute.php index a08c5456..f9ba6fd5 100644 --- a/services/nginx/app/routes/moduleEconomicCustomerRoute.php +++ b/services/nginx/app/routes/moduleEconomicCustomerRoute.php @@ -37,7 +37,11 @@ class moduleEconomicCustomerRoute (new logs_o())->add('modules_economic', 'global', 0, 0, 'MODULES_ECONOMIC', 'User tried to access the customer without a valid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'modules_economic_customer_get' => 'Get customer' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/moduleEconomicRoute.php b/services/nginx/app/routes/moduleEconomicRoute.php index 8643bac8..6ef71a13 100644 --- a/services/nginx/app/routes/moduleEconomicRoute.php +++ b/services/nginx/app/routes/moduleEconomicRoute.php @@ -57,7 +57,11 @@ class moduleEconomicRoute (new logs_o())->add('economic', 'global', 1, 0, 'ECONOMIC_IMPORT_CUSTOMER', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'economic_import_customer' => 'Import customer from economic' + ] + ); /** Economic > Departments > GET */ self::get('/economic/departments', function () { @@ -89,7 +93,11 @@ class moduleEconomicRoute // Return the error $response->error('Invalid session', 400); } - }); + }, + [ + 'economic_departments_get' => 'Get departments from economic' + ] + ); /** Economic > Products > GET */ self::get('/economic/products', function () { @@ -124,6 +132,10 @@ class moduleEconomicRoute // Return the error $response->error('Invalid session', 400); } - }); + }, + [ + 'economic_products_get' => 'Get products from economic' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/moduleMotorAPIRoute.php b/services/nginx/app/routes/moduleMotorAPIRoute.php index 9a1a1b61..d23673e8 100644 --- a/services/nginx/app/routes/moduleMotorAPIRoute.php +++ b/services/nginx/app/routes/moduleMotorAPIRoute.php @@ -37,7 +37,11 @@ class moduleMotorAPIRoute (new logs_o())->add('modules_motorapi', 'global', 1, 0, 'MODULES_MOTORAPI', 'No user found, or invalid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'modules_motorapi_lookup' => 'Lookup license plate information' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/moduleStripeRoute.php b/services/nginx/app/routes/moduleStripeRoute.php index f7da8dde..fa785374 100644 --- a/services/nginx/app/routes/moduleStripeRoute.php +++ b/services/nginx/app/routes/moduleStripeRoute.php @@ -36,7 +36,11 @@ class moduleStripeRoute (new logs_o())->add('modules_stripe', 'global', 0, 0, 'MODULES_STRIPE', 'User tried to access the customers list without a valid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'modules_stripe_customers_list' => 'List all customers' + ] + ); /** Modules > Stripe > Products > List */ $this->get('/modules/stripe/products', function () { @@ -51,7 +55,11 @@ class moduleStripeRoute (new logs_o())->add('modules_stripe', 'global', 0, 0, 'MODULES_STRIPE', 'User tried to access the products list without a valid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'modules_stripe_products_list' => 'List all products' + ] + ); /** Modules > Stripe > Prices > List */ $this->get('/modules/stripe/prices', function () { @@ -66,7 +74,11 @@ class moduleStripeRoute (new logs_o())->add('modules_stripe', 'global', 0, 0, 'MODULES_STRIPE', 'User tried to access the prices list without a valid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'modules_stripe_prices_list' => 'List all prices' + ] + ); /** Modules > Stripe > Send Invoice */ $this->post('/modules/stripe/invoice', function () { @@ -122,6 +134,10 @@ class moduleStripeRoute (new logs_o())->add('modules_stripe', 'global', 0, 0, 'MODULES_STRIPE', 'User tried to send an invoice without a valid session'); $response->error('Invalid session', 400); } - }); + }, + [ + 'modules_stripe_invoice_send' => 'Send invoice' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/orderItemsRoute.php b/services/nginx/app/routes/orderItemsRoute.php index 702f3064..130ab68a 100644 --- a/services/nginx/app/routes/orderItemsRoute.php +++ b/services/nginx/app/routes/orderItemsRoute.php @@ -46,7 +46,11 @@ class orderItemsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'add_order_items' => 'Add order items' + ] + ); $this->get('/order/items', function () { // Require the user to be logged in @@ -84,7 +88,11 @@ class orderItemsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'list_order_items' => 'List all order items' + ] + ); $this->delete('/order/items', function () { // Require the user to be logged in @@ -112,7 +120,11 @@ class orderItemsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'delete_order_items' => 'Delete order items' + ] + ); $this->put('/order/items', function () { // Require the user to be logged in @@ -154,6 +166,10 @@ class orderItemsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'edit_order_items' => 'Edit order items' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/orderRoute.php b/services/nginx/app/routes/orderRoute.php index 77177967..164f21a3 100644 --- a/services/nginx/app/routes/orderRoute.php +++ b/services/nginx/app/routes/orderRoute.php @@ -41,7 +41,11 @@ class orderRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'fetch_order' => 'Fetch order' + ] + ); $this->put('/order', function () { @@ -77,6 +81,10 @@ class orderRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'update_order' => 'Update order' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/ordersRoute.php b/services/nginx/app/routes/ordersRoute.php index 8225315a..2cbbec21 100644 --- a/services/nginx/app/routes/ordersRoute.php +++ b/services/nginx/app/routes/ordersRoute.php @@ -54,7 +54,11 @@ class ordersRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'list_orders' => 'List all orders' + ] + ); $this->post('/orders', function () { @@ -100,7 +104,11 @@ class ordersRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'add_order' => 'Add an order' + ] + ); $this->put('/orders', function () { // Require the user to be logged in @@ -152,7 +160,11 @@ class ordersRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'edit_order' => 'Edit an order' + ] + ); $this->delete('/orders', function () { // Require the user to be logged in @@ -186,7 +198,11 @@ class ordersRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'delete_order' => 'Delete an order' + ] + ); } /** diff --git a/services/nginx/app/routes/plateScannersRoute.php b/services/nginx/app/routes/plateScannersRoute.php index 23d78b66..6dc248d6 100644 --- a/services/nginx/app/routes/plateScannersRoute.php +++ b/services/nginx/app/routes/plateScannersRoute.php @@ -41,7 +41,11 @@ class plateScannersRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'list_number_plate_scanners' => 'List all number plate scanners' + ] + ); $this->post('/numberplatescanners', function () { // Require the user to be logged in @@ -75,7 +79,11 @@ class plateScannersRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'add_number_plate_scanner' => 'Add a number plate scanner' + ] + ); $this->put('/numberplatescanners', function () { // Require the user to be logged in @@ -112,6 +120,10 @@ class plateScannersRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'edit_number_plate_scanner' => 'Edit a number plate scanner' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/plateScansRoute.php b/services/nginx/app/routes/plateScansRoute.php index 4fcb484e..7eda3f6f 100644 --- a/services/nginx/app/routes/plateScansRoute.php +++ b/services/nginx/app/routes/plateScansRoute.php @@ -67,7 +67,9 @@ class plateScansRoute // Return an error $response->error('Invalid session', 400); } - }); + }, [ + 'list_number_plate_scans_department' => 'List all number plate scans for a department' + ]); $this->get('/numberplatescans', function () { // Require the user to be logged in @@ -89,6 +91,8 @@ class plateScansRoute // Return an error $response->error('Invalid session', 400); } - }); + }, [ + 'list_number_plate_scans' => 'List all number plate scans' + ]); } } \ No newline at end of file diff --git a/services/nginx/app/routes/productOptionsRoute.php b/services/nginx/app/routes/productOptionsRoute.php index 6ab3b3f2..57a2f187 100644 --- a/services/nginx/app/routes/productOptionsRoute.php +++ b/services/nginx/app/routes/productOptionsRoute.php @@ -52,7 +52,11 @@ class productOptionsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'list_product_options' => 'List all product options' + ] + ); $this->post('/product/options', function () { // Require the user to be logged in @@ -86,7 +90,11 @@ class productOptionsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'add_product_option' => 'Add a product option' + ] + ); $this->put('/product/options', function () { // Require the user to be logged in @@ -118,6 +126,10 @@ class productOptionsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'edit_product_option' => 'Edit a product option' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/productsRoute.php b/services/nginx/app/routes/productsRoute.php index e7601b81..41d730ea 100644 --- a/services/nginx/app/routes/productsRoute.php +++ b/services/nginx/app/routes/productsRoute.php @@ -81,7 +81,11 @@ class productsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'list_products' => 'List all products' + ] + ); $this->post('/products', function () { // Require the user to be logged in @@ -124,7 +128,11 @@ class productsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'add_product' => 'Add a product' + ] + ); $this->put('/products', function () { // Require the user to be logged in @@ -173,6 +181,10 @@ class productsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'edit_product' => 'Edit a product' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/sessionRoute.php b/services/nginx/app/routes/sessionRoute.php index 2376705e..e613d8e6 100644 --- a/services/nginx/app/routes/sessionRoute.php +++ b/services/nginx/app/routes/sessionRoute.php @@ -30,6 +30,10 @@ class sessionRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'fetch_session' => 'Fetch session' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/statisticsRoute.php b/services/nginx/app/routes/statisticsRoute.php index c78d9588..17fd4204 100644 --- a/services/nginx/app/routes/statisticsRoute.php +++ b/services/nginx/app/routes/statisticsRoute.php @@ -42,7 +42,11 @@ class statisticsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'statistics_bookings_new' => 'List all new bookings' + ] + ); /** Statistics >> Orders >> New orders */ $this->get('/statistics/orders/new', function () { @@ -72,7 +76,11 @@ class statisticsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'statistics_orders_new' => 'List all new orders' + ] + ); /** Statistics >> Economic >> Total income */ $this->get('/statistics/economic/totals', function () { @@ -102,7 +110,11 @@ class statisticsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'statistics_economic_income' => 'Get total income' + ] + ); /** Statistics >> Economic >> Department sent invoice totals */ $this->get('/statistics/economic/totals/department_sent_invoice_totals', function () { @@ -132,7 +144,11 @@ class statisticsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'statistics_economic_department_sent_invoice_totals' => 'Get department sent invoice totals' + ] + ); /** Statistics >> Economic >> Department draft invoice totals */ $this->get('/statistics/economic/totals/department_draft_invoice_totals', function () { @@ -162,7 +178,11 @@ class statisticsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'statistics_economic_department_draft_invoice_totals' => 'Get department draft invoice totals' + ] + ); /** Statistics >> Economic >> Total income today */ $this->get('/statistics/income/today', function () { @@ -191,7 +211,11 @@ class statisticsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'statistics_economic_income_today' => 'Get total income today' + ] + ); /** Statistics >> Economic >> Total income yesterday */ $this->get('/statistics/income/yesterday', function () { @@ -220,7 +244,11 @@ class statisticsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'statistics_economic_income_yesterday' => 'Get total income yesterday' + ] + ); /** Statistics >> Economic >> Total income this month */ $this->get('/statistics/income/this-month', function () { @@ -249,7 +277,11 @@ class statisticsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'statistics_economic_income_this_month' => 'Get total income this month' + ] + ); /** Statistics >> Economic >> Total income last month */ $this->get('/statistics/income/last-month', function () { @@ -278,7 +310,11 @@ class statisticsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'statistics_economic_income_last_month' => 'Get total income last month' + ] + ); /** Statistics >> Economic >> Total income this year */ $this->get('/statistics/income/this-year', function () { @@ -307,7 +343,11 @@ class statisticsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'statistics_economic_income_this_year' => 'Get total income this year' + ] + ); $this->get('/statistics/income/departments', function () { // Require the user to be logged in @@ -349,6 +389,10 @@ class statisticsRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'statistics_economic_income_today_departments' => 'Get total income today by departments' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/superuserDepartmentRoute.php b/services/nginx/app/routes/superuserDepartmentRoute.php index f9f7caea..4e2ed9ec 100644 --- a/services/nginx/app/routes/superuserDepartmentRoute.php +++ b/services/nginx/app/routes/superuserDepartmentRoute.php @@ -45,7 +45,9 @@ class superuserDepartmentRoute // Return an error $response->error('Invalid session', 400); } - }); + }, [ + 'superuser_fetch_department' => 'Fetch department' + ]); $this->post('/superuser/department/prices', function () { // Require the user to be logged in @@ -105,7 +107,9 @@ class superuserDepartmentRoute // Return an error $response->error('Invalid session', 400); } - }); + }, [ + 'superuser_set_department_prices' => 'Set department prices' + ]); $this->get('/superuser/department/prices', function () { // Require the user to be logged in @@ -138,6 +142,8 @@ class superuserDepartmentRoute // Return an error $response->error('Invalid session', 400); } - }); + }, [ + 'superuser_fetch_department_prices' => 'Fetch department prices' + ]); } } \ No newline at end of file diff --git a/services/nginx/app/routes/userOrdersRoute.php b/services/nginx/app/routes/userOrdersRoute.php index 934cbf8c..570e6bfa 100644 --- a/services/nginx/app/routes/userOrdersRoute.php +++ b/services/nginx/app/routes/userOrdersRoute.php @@ -41,7 +41,11 @@ class userOrdersRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'list_own_orders' => 'List own orders' + ] + ); $this->get('/user/order', function () { // Require the user to be logged in @@ -76,6 +80,10 @@ class userOrdersRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'fetch_own_order' => 'Fetch own order' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/userRoute.php b/services/nginx/app/routes/userRoute.php index 42b2f230..bd02d680 100644 --- a/services/nginx/app/routes/userRoute.php +++ b/services/nginx/app/routes/userRoute.php @@ -42,7 +42,11 @@ class userRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'get_user' => 'Get user' + ] + ); $this->get('/superuser/user/discounts', function () { // Require the user to be logged in @@ -72,7 +76,11 @@ class userRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'get_custom_prices_other' => 'Get custom prices for other users' + ] + ); $this->post('/superuser/user/discounts', function () { // Require the user to be logged in @@ -131,7 +139,11 @@ class userRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'set_custom_price' => 'Set custom price' + ] + ); $this->get('/admin/customer/getUserId', function () { // Require the user to be logged in @@ -163,6 +175,10 @@ class userRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'get_user_id' => 'Get user id' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/usersRoute.php b/services/nginx/app/routes/usersRoute.php index 10f3b91f..56a53781 100644 --- a/services/nginx/app/routes/usersRoute.php +++ b/services/nginx/app/routes/usersRoute.php @@ -46,7 +46,11 @@ class usersRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'list_users' => 'List all users' + ] + ); $this->get('/users/customer', function () { // Require the user to be logged in @@ -75,7 +79,11 @@ class usersRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'get_user_from_customer_number' => 'Get user from customer number' + ] + ); $this->post('/users', function () { // Require the user to be logged in @@ -109,7 +117,11 @@ class usersRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'add_user' => 'Add a user' + ] + ); $this->put('/users', function () { // Require the user to be logged in @@ -160,7 +172,11 @@ class usersRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'edit_user' => 'Edit a user' + ] + ); $this->get('/public/employees', function () { // This route is public, no authentication is required. @@ -177,6 +193,10 @@ class usersRoute $response->success( $publicData ); - }); + }, + [ + 'list_public_employees' => 'List all public employees' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/vehiclePlateLastOrdersRoute.php b/services/nginx/app/routes/vehiclePlateLastOrdersRoute.php index 16260d6b..c3391e20 100644 --- a/services/nginx/app/routes/vehiclePlateLastOrdersRoute.php +++ b/services/nginx/app/routes/vehiclePlateLastOrdersRoute.php @@ -37,6 +37,10 @@ class vehiclePlateLastOrdersRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'department_vehicle_order_last_five' => 'Fetch the last five orders for a vehicle plate' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/vehiclePlateLookupRoute.php b/services/nginx/app/routes/vehiclePlateLookupRoute.php index c755997c..68d6670d 100644 --- a/services/nginx/app/routes/vehiclePlateLookupRoute.php +++ b/services/nginx/app/routes/vehiclePlateLookupRoute.php @@ -39,7 +39,7 @@ class vehiclePlateLookupRoute } }, [ - 'department_license_plate_lookup' => 'Department license plate lookup' + 'department_license_plate_lookup' => 'Departmental access to lookup a license plate and view the order history' ] ); @@ -88,6 +88,10 @@ class vehiclePlateLookupRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'department_license_plate_lookup' => 'List all the records for a specific customer number and registration number column in the orders table' + ] + ); } } \ No newline at end of file diff --git a/services/nginx/app/routes/vehiclesRoute.php b/services/nginx/app/routes/vehiclesRoute.php index e7595b89..0f0ee8a0 100644 --- a/services/nginx/app/routes/vehiclesRoute.php +++ b/services/nginx/app/routes/vehiclesRoute.php @@ -5,7 +5,6 @@ namespace routes; use classes\authentication; use objects\customer_vehicles_o; use objects\logs_o; -use objects\users_o; use traits\route_t; class vehiclesRoute @@ -38,7 +37,11 @@ class vehiclesRoute // Return an error $response->error('Invalid session', 400); } - }); + }, + [ + 'list_own_vehicles' => 'List own vehicles' + ] + ); $this->post('/user/vehicles', function () { // Require the user to be logged in @@ -75,7 +78,11 @@ class vehiclesRoute // Return an error $response->error('Invalid session', 401); } - }); + }, + [ + 'add_vehicle' => 'Add a vehicle to own vehicles' + ] + ); } private function getData(mixed $data, $response) diff --git a/services/nginx/app/routes/washCertificateRoute.php b/services/nginx/app/routes/washCertificateRoute.php index 43fcbcc4..97692e35 100644 --- a/services/nginx/app/routes/washCertificateRoute.php +++ b/services/nginx/app/routes/washCertificateRoute.php @@ -18,6 +18,10 @@ class washCertificateRoute // Run the index.php file require_once 'index.php'; exit(); - }); + }, + [ + 'modules_washcertificates' => 'Get all wash certificates' + ] + ); } } \ No newline at end of file