Commit Graph
100 Commits
Author SHA1 Message Date
Jeppe Bundgaard b291e959e0 Add WebAuthn integration, reCAPTCHA support, and new tests
- Integrate WebAuthn library for passkey authentication workflows, including assertion verification and improved error handling.
- Add support for reCAPTCHA token validation across multiple endpoints for enhanced security.
- Extend OpenAPI schema to document new fields and restructured payloads.
- Add unit tests for WebAuthn flows, permission initialization, and route validation to ensure robustness and accuracy.
2026-02-24 09:27:51 +01:00
Jeppe Bundgaard 2e88ed7bbd Add binding for acme-io.json in Traefik config 2026-02-24 00:28:17 +01:00
Jeppe Bundgaard 629c13499d Add CORS rule for api.truckwash.io and new preflight route
- Introduce preflight handling for `OPTIONS` method on `api.truckwash.io` with high priority routing and secure headers middleware.
- Extend CORS configuration to include `https://api.truckwash.io`.
2026-02-23 23:45:22 +01:00
Jeppe Bundgaard 356e59bd10 Improve dynamic URL generation and add localhost support for passkey challenges
- Refactor direct download URL generation to dynamically use `HTTP_HOST` and protocol.
- Add support for localhost `rpId` during WebAuthn passkey challenges.
- Extend test cases to validate `localhost` and `truckwash.io` scenarios.
- Update OpenAPI specifications to reflect new `rpId` logic and additional server configurations.
2026-02-23 23:37:15 +01:00
Jeppe Bundgaard 61db62212c Add WebAuthn passkey challenge and verification endpoints
- Introduced endpoints for WebAuthn-based authentication flow (`/auth/passkey/challenge` and `/auth/passkey/verify`).
- Added support for generating and verifying WebAuthn PublicKeyCredentialRequestOptions and challenge tokens.
- Extended routing logic to expose matched route templates for improved parameter handling.
- Updated OpenAPI specifications to document passkey challenge and verification workflows.
- Included unit tests for validating both existing and non-existing user scenarios during passkey challenges.
2026-02-23 23:03:28 +01:00
Jeppe Bundgaard 63c88a463d Refactor passkey and token processing for improved consistency and validation
- Update passkey data mapping to use associative arrays and handle JSON decoding for `transports`.
- Refactor token caching logic to validate database existence and clear stale entries.
- Improve 2FA handling by centralizing `token->type` and `user_id` processing for reuse.
2026-02-23 22:44:06 +01:00
Jeppe Bundgaard 8ae0e28162 Add sign_count and backup_state properties to passkey object initialization 2026-02-23 22:01:09 +01:00
Jeppe Bundgaard eb0f4ca38b Enhance 2FA handling and subuser session management
- Add `two_factor_enabled` property for subuser responses in routes and OpenAPI specs.
- Improve subuser session resolution by checking token `id` for validity.
- Adjust authentication flow to prevent operations on nonexistent users in 2FA logic.
- Update OpenAPI request/response schema to better represent token/session objects.
2026-02-23 21:44:11 +01:00
Jeppe Bundgaard ce889053a6 Improve subuser session handling and 2FA logic
- Add fallback logic to resolve subuser sessions via the tokens table when cache is missing or expired, with re-caching for future use.
- Refactor 2FA flow to prioritize subuser over user objects for better clarity and ensure compatibility with TOTP logic.
- Add safeguards to avoid operations on nonexistent users or subusers in 2FA and authentication flows.
2026-02-23 18:57:20 +01:00
Jeppe Bundgaard f6b526f4ef Add two-factor authentication support for users and subusers
- Extend `users_o` and `subusers_o` with `two_factor_enabled` and `two_factor_secret` properties.
- Implement methods for managing 2FA (`isTwoFactorEnabled`, `setTwoFactorSecret`, `verify_2fa_code`) in authentication logic.
- Add 2FA handling in login flows for both users and subusers, including token generation and validation.
- Introduce `totp` class for TOTP-based authentication, including QR code generation and code verification.
- Add test cases for 2FA functionality (`TwoFactorAuthTest.php`) and coverage for login scenarios with 2FA.
- Update OpenAPI specifications to include 2FA flows (`auth/2fa/setup`, `auth/2fa/enable`, `auth/2fa/verify`, `auth/2fa/disable`).
2026-02-23 17:00:18 +01:00
Jeppe Bundgaard 827fafd46b Add validation to prevent duplicate company phone numbers during customer registration 2026-02-23 16:30:51 +01:00
Jeppe Bundgaard 5a59562e35 Add Bird API integration with voice call and flash call support
- Implement Bird API client (`bird.php`) for handling HTTP requests to Bird services.
- Add routes for voice and flash call management (`birdVoiceFlashCallsRoute.php`, `birdNumbersRoute.php`).
- Introduce test cases for voice calls, flash calls, and numbers (`VoiceCallsApiTest.php`, `NumbersAndFlashCallsApiTest.php`).
- Include configuration management classes and APIs for enabling the Bird module and managing API keys (`bird_c.php`).
- Provide OpenAPI specifications for flash call endpoints (`bird-flash-calls.md`).
2026-02-19 12:19:36 +01:00
Jeppe Bundgaard 6d09e5449e Enhance MACHINE relay control logic and add emergency override functionality
- Add `forceTurnOffMachineRelay` method for superuser/emergency operations to bypass gating restrictions.
- Enforce `toggle_after = 0` to prevent auto-toggle behavior.
- Update routes to explicitly reflect relay state when modifying MACHINE relay.
- Extend Shelly device switch handling with optional `skip_toggle_after` parameter.
2026-02-19 11:37:16 +01:00
Jeppe Bundgaard aaaaedc70c Add tests for forced MACHINE relay control endpoints
- Introduce HTTP tests for `/modules/self-serve/lane/force/machine/enable` and `/disable`.
- Add `ForceMachineRelayBypassTest` to validate bypass behavior of manual gating restrictions.
2026-02-19 11:07:44 +01:00
Jeppe Bundgaard 4bdbe40329 Add superuser endpoints for forced MACHINE relay control
- Implement emergency operations to forcibly enable or disable MACHINE relays (`forceTurnOnMachineRelay`).
- Add OpenAPI specifications for `/modules/self-serve/lane/force/machine/enable` and `/modules/self-serve/lane/force/machine/disable`.
- Update route definitions and introduce validation for input parameters.
2026-02-19 10:39:43 +01:00
Jeppe Bundgaard 54160659fc Add dynamic image generation for department lanes
- Implement `/department/lanes/dynamic-image` endpoint for machine UI dynamic image rendering.
- Add OpenAPI specification for the new endpoint with query parameters for buttons, current step, and vehicle type.
- Include `DepartmentLanesImageTest` for lightweight testing of image behavior and input normalization.
- Update `departmentLanesRoute.php` with logic for parameter handling and image composition based on lane configuration.
2026-02-18 16:44:18 +01:00
Jeppe Bundgaard 73ac77a2f5 Add support for dynamic image buttons and vehicle type selection in self-serve tasks
- Extend `department_selfserve_tasks_o` with `buttons` and `dynamic_images_vehicle_type` properties.
- Add normalization/validation methods for `buttons` and `dynamic_images_vehicle_type` parameters.
- Update `departmentSelfserveTasksRoute` to handle new fields in task creation and update.
- Add OpenAPI specifications for `buttons` and `dynamic_images_vehicle_type`.
- Include comprehensive tests for button normalization and vehicle type selection.
2026-02-18 16:34:58 +01:00
Jeppe Bundgaard 28a4a9d8e6 Add StopTurnsOffRelayTest to verify machine relay behavior during STOP with self-serve enabled
- Introduce a minimal, self-contained test to ensure the relay turns off when STOP is executed.
- Enhance `selfserve_lane_command_t` to handle relay shutdown based on department configuration.
- Include `isDepartmentSelfServeEnabled` method for testing override and I/O avoidance.
2026-02-18 16:14:33 +01:00
Jeppe Bundgaard 9881e57698 Ensure proper initialization of lane status via getter methods, refactor email template structure for better MSO compatibility, and add machine_available field to guest API response. 2026-02-18 16:06:14 +01:00
Jeppe Bundgaard f292152135 Improve email templates with MSO compatibility and enhanced styling
- Refactor header and footer to support Outlook Classic (MSO) rendering.
- Adjust logo sizing, alignment, and styles for improved consistency.
- Update inline styles for better cross-platform email rendering.
2026-02-18 15:43:19 +01:00
Jeppe Bundgaard 3f512a4fa6 Refine new customer welcome email template with inline styles, improved accessibility, and MSO-specific adjustments 2026-02-18 15:42:14 +01:00
Jeppe Bundgaard c5840c0f3e Add self-serve module loading, enum test, and update email styles/text
- Add `SelfserveLaneServicesEnumTest` to validate `selfserve_lane_services` cases.
- Update `index.php` to load self-serve module interfaces, traits, classes, helpers, and configs.
- Center Truck Wash logo in email header and adjust styling.
- Localize password reset error message in `authRoute.php` with Danish text.
2026-02-18 15:35:41 +01:00
Jeppe Bundgaard 51014bf774 Add development guidelines, testing rules, and secure routes documentation
- Add `.junie/guidelines.md` with comprehensive development instructions.
- Include `.aiassistant/rules/Creating and maintaining tests.md` and `.aiassistant/rules/Creating and securing routes.md`.
- Introduce `CACHE_SELFSERVE_LANE_KEY_ALLOWED_SERVICES` for lane service validation.
- Update `selfserve_lane_relay_controller_t` to enforce service-specific permissions for machine relay.
2026-02-18 14:13:05 +01:00
Jeppe Bundgaard 008e2af09a Add support for self-serve task services and validation logic
- Introduce `services` property to `department_selfserve_tasks_o` for task-specific functionalities.
- Add service validation and normalization via `selfserve_lane_services` enum.
- Extend `departmentSelfserveTasksRoute` to handle `services` input for add/edit operations.
- Create `selfserve_lane_services` enum to define and validate service types.
2026-02-18 12:47:00 +01:00
Jeppe Bundgaard efaed8c6cc Refactor new customer email template and attachments handling
- Update welcome email template to conditionally include corporate ID.
- Remove unused base64 signature utility and clean up the email class.
- Comment out attachments array for potential future updates.
2026-02-17 12:07:03 +01:00
Jeppe Bundgaard b7648ccc2c Update new customer email template with dynamic company data and revised signature assets
- Dynamically insert company name and corporate ID in welcome message.
- Replace signature image URLs with updated assets and ensure proper loading.
- Add utility for retrieving base64-encoded signatures to enhance flexibility.
2026-02-17 12:01:10 +01:00
Jeppe Bundgaard a31187879b Refine new customer welcome email template with enhanced styles and improved HTML structure 2026-02-17 11:46:33 +01:00
Jeppe Bundgaard 3e76bdccc2 Add HTML email template for new customer welcome email and integrate into email class 2026-02-17 11:43:14 +01:00
Jeppe Bundgaard 0a582951a0 Add new HTML email template and assets for welcoming new Truckwash customers 2026-02-17 11:37:49 +01:00
Jeppe Bundgaard fc054d6226 Expand CORS allowlist in Traefik to include http://localhost:5173 for development purposes 2026-02-17 11:37:35 +01:00
Jeppe Bundgaard 4d2264e51e Expand CORS allowlist in Traefik to include additional Truckwash domains and localhost 2026-02-17 09:23:33 +01:00
Jeppe Bundgaard 241a05e498 Send additional welcome emails to info@truckwash.dk and jm@truckwash.dk when creating new customers 2026-02-16 15:44:53 +01:00
Jeppe Bundgaard e6358d09fc Ensure isWashCertificate check is case-insensitive in attachment.php 2026-02-16 15:32:37 +01:00
Jeppe Bundgaard 1791a62992 Remove port from file download URLs in attachment_store.php and upload_store.php 2026-02-16 15:10:38 +01:00
Jeppe Bundgaard 0c411fa3b8 Add deprecated /tmp-send-email route with welcome email functionality
- Introduce a temporary route to send deprecated responses for email testing.
- Use `sendWelcomeEmailToCustomer` from the `email` class to implement email-sending logic.
2026-02-16 14:57:47 +01:00
Jeppe Bundgaard 4248de1d7d Add password reset link generation and welcome email functionality
- Introduce `generatePasswordResetLink` method in `users_o` for creating secure password reset links.
- Add `sendWelcomeEmailToCustomer` method to `email` class with support for attachments.
- Update `authRoute.php` to send welcome emails when creating new customers.
- Extend `sendEmail` to handle optional attachments and references.
- Disable PHP entrypoint in Dockerfile for improved flexibility.
2026-02-16 14:55:01 +01:00
Jeppe Bundgaard 29a07e652c Enhance CORS handling in Traefik and Caddy
- Add preflight routers and attach `secure-headers` middleware in Traefik for `api.truckwash.dk` and `cloud.truckwash.dk`.
- Update `secure-headers` middleware with refined CORS headers and stricter origin/method/header configurations.
- Remove redundant CORS logic in Caddy, delegating CORS management entirely to Traefik.
2026-02-16 13:25:54 +01:00
Jeppe Bundgaard dd33fa2b19 Update CORS handling in Traefik and Caddy configurations
- Add origin-specific CORS settings to Traefik for `truckwash.io` with credentials support.
- Simplify and standardize CORS headers in Caddy, removing upstream duplication and adjusting preflight logic.
2026-02-16 13:08:38 +01:00
Jeppe Bundgaard 22790705b4 Disable auto HTTPS and improve CORS handling in Caddyfile for internal HTTP and simplified preflight responses. 2026-02-16 12:35:03 +01:00
Jeppe Bundgaard 0ec8339d3e Simplify CORS handling in Caddyfile by allowing all origins and updating preflight response logic. 2026-02-16 12:31:06 +01:00
Jeppe Bundgaard 739beced0d Expand CORS support in Caddyfile to include truckwash.io subdomains alongside truckwash.dk and localhost. 2026-02-16 12:21:46 +01:00
Jeppe Bundgaard ac542a705e Update Caddyfile with refined CORS handling and stricter origin matching for truckwash.dk subdomains and localhost 2026-02-16 12:21:02 +01:00
Jeppe Bundgaard fe0e02b8fe Add Redis healthchecks and startup wait in PHP entrypoint
- Introduce Redis healthchecks in `docker-compose.prod.yml` for better container monitoring.
- Extend PHP Dockerfile with `redis-tools` and enable Composer dependency auto-install.
- Update `docker-entrypoint.sh` to wait for Redis readiness before starting PHP-FPM.
- Remove local Nginx override and simplify development setup.
2026-02-16 12:18:42 +01:00
Jeppe Bundgaard a709656ba3 Add production-ready Traefik configuration with secure headers, TLS settings, and rate limiting 2026-02-16 11:39:28 +01:00
Jeppe Bundgaard 21f64bbb5f Add Prometheus metrics and Jaeger tracing to Traefik configuration 2026-02-16 11:32:24 +01:00
Jeppe Bundgaard 7c2b6f1357 Update Traefik dynamic config with bcrypt-hashed credentials for truckwash. 2026-02-16 11:26:40 +01:00
Jeppe Bundgaard c7ea1e1aaa Add Traefik and Caddy configurations for reverse proxy setup and internal HTTP handling. 2026-02-16 11:15:20 +01:00
Jeppe Bundgaard 8c8de541be - Update Nginx logging with structured JSON and standard combined format for Elastic integration.
- Add new upstream PHP-FPM servers to Nginx configuration for enhanced load balancing.
- Introduce Elastic APM PHP agent in `php.ini` and update Dockerfile for better dependency management.
- Secure Kibana and Elasticsearch connections in Metricbeat/Filebeat configurations with credentials.
- Remove unused PHP dependencies from `composer.json` and `composer.lock`.
2026-02-16 10:58:50 +01:00
Jeppe Bundgaard 8d8137852f Adjust Monday message time check and add deprecated route with CSV export functionality
- Update the Monday message check to start at 07:00 instead of 06:00.
- Add `/tmp-washes-in-time` route to generate and download a CSV file of washes within a specific time range.
- Mark `/tmp-washes-in-time` route as deprecated.
2026-02-16 09:25:11 +01:00
Jeppe Bundgaard 50003c62c4 Add Metricbeat integration for system, Docker, and Nginx metrics
- Enable Nginx `stub_status` endpoint on port 8080 for internal metric collection.
- Add Metricbeat configuration for system, Docker, and Nginx metrics, integrating with Elasticsearch and Kibana.
2026-02-13 22:39:27 +01:00
Jeppe Bundgaard 081d8ad284 Add Dockerfile and entrypoint optimizations, Composer auto-install, and dependency updates
- Use `__DIR__` for `vendor/autoload.php` in PHP autoload path.
- Add Composer dependency auto-installation at container startup with `docker-entrypoint.sh`.
- Extend Docker image to include `libssl-dev` and `ca-certificates` for TLS support.
- Enable dynamic installation of application dependencies during runtime via entrypoint.
- Update Composer dependencies, including AWS SDK, Guzzle, and OpenTelemetry libraries.
2026-02-13 22:21:46 +01:00
Jeppe Bundgaard e66aaecac5 Add Nginx development configuration and Docker Compose override for local setup
- Define HTTP-only Nginx configuration with structured JSON logging and PHP-FPM upstream.
- Add gzip compression, CORS headers, and request ID handling for local development.
- Expose Nginx on port 80 with Docker Compose override file.
2026-02-13 21:22:31 +01:00
Jeppe Bundgaard d7a8fc1d1c Add Nginx TLS configuration, structured logging, PHP-FPM upstream, and Filebeat integration
- Configure Nginx to use structured JSON access logs and add request ID headers.
- Define upstream pool for PHP-FPM with load-balancing support.
- Integrate Filebeat for log ingestion across Nginx and PHP logs.
- Add `.env.example` and README for local TLS setup guidance.
- Extend Dockerfile with PHP extensions (GD, Redis, etc.) and Composer dependency installs.
- Add custom PHP configuration for Redis-backed session storage.
2026-02-13 21:10:50 +01:00
Jeppe Bundgaard aae244887f Extend CORS headers to include X-Customer-Number and add customer context in subuser grants. 2026-02-12 18:12:29 +01:00
Jeppe Bundgaard 05a4943162 Add /subusers/me route for public registration and extend OpenAPI schema
- Add `/subusers/me` as a public registration endpoint, including CVR validation, phone lookup, and optional SMS setup link generation.
- Extend OpenAPI specification with `SubuserSelf` and `SubuserGrantSummary` schemas for returning authenticated subuser profiles and grants.
2026-02-12 16:58:41 +01:00
Jeppe Bundgaard 17701cae69 Refactor subusersRoute to implement dynamic permission handling and effective customer context
- Add `allowOwnOrDepartmentAccess` for scoped permission checks across subuser routes.
- Introduce effective customer resolution using `resolveEffectiveCustomerNumber`.
- Enforce subuser-specific permissions with dynamic grants (`list_own_subuser_grants`, `add_own_subusers`, etc.).
- Update error handling to validate customer context and ensure node-based permission checks.
- Add localized descriptions for new and existing permission nodes.
2026-02-12 16:52:40 +01:00
Jeppe Bundgaard 78a0e9869e Refactor ordersRoute to include targetCustomerNumber in permission checks
- Use `resolveEffectiveCustomerNumber` for determining customer context.
- Adjust own/department access logic and remove unnecessary casting for `customer_id`.
2026-02-12 16:39:49 +01:00
Jeppe Bundgaard 6302fd25df Extend subuser permission system and refactor route permission handling
- Update `subusersRoute` to support subuser authentication and permission checks dynamically.
- Add new permission nodes (`SELFSERVE_LIST`, `SELFSERVE_EDIT`, `SELFSERVE_DELETE`) in `subusers_permission_node_key`.
- Fix typos in vehicle permission constants and ensure proper resolution.
- Enhance `vehiclesRoute` with effective customer context and scoped permission checks.
- Localize new permission nodes with descriptions in Danish.
2026-02-12 16:26:29 +01:00
Jeppe Bundgaard 19139b08cb Extend authentication to handle subuser tokens with customer number resolution 2026-02-12 16:17:32 +01:00
Jeppe Bundgaard 4f9f2a2d71 Enhance API documentation and extend customer context handling for subuser permissions
- Add `X-Customer-Number` header for subuser-specific customer targeting across endpoints.
- Update vehicle-related endpoints (`listVehicles`, `addVehicle`, `editVehicle`, etc.) to include subuser permission checks and customer context handling.
- Refactor request and response schemas for vehicle operations to reflect new requirements and improve clarity.
- Include detailed permission scoping and descriptions for subuser and broader access handling.
- Extend OpenAPI specification with enriched schema properties and additional responses for edge cases.
2026-02-12 16:01:30 +01:00
Jeppe Bundgaard 16094575a7 Refactor ordersRoute, vehiclesRoute, and related routes for subuser permission handling
- Integrate `subusers_permission_node_key` for dynamic subuser-specific permission checks.
- Refactor authentication and permission logic to streamline checks for own vs. department-level access.
- Simplify error handling and enforce scoped permissions for vehicles, orders, and their attachments.
- Localize permission labels and descriptions to Danish for relevant modules.
2026-02-12 15:52:37 +01:00
Jeppe Bundgaard f265a83034 Refactor route_t and orderBookingRoute to simplify permission handling
- Add reusable helpers: `isOwnCustomerContext`, `resolveEffectiveCustomerNumber`, and `allowOwnOrDepartmentAccess` in `route_t` for streamlined permission checks.
- Replace inlined permission logic in `orderBookingRoute` with common helpers for creating, viewing, editing, and deleting bookings.
- Localize permission names, descriptions, and labels to Danish across relevant modules.
- Improve error handling and simplify context resolution for subuser and department-level permissions.
2026-02-12 15:43:02 +01:00
Jeppe Bundgaard cd894b4e3b Refactor orderBookingRoute to integrate subuser-specific permission checks
- Add dynamic authentication and subuser permission handling using `subusers_permission_node_key`.
- Refactor route-level permission logic for creating, viewing, editing, and deleting bookings to respect subuser context.
- Ensure proper error handling for unauthorized access and enforce departmental scope for admin-level actions.
2026-02-12 15:37:03 +01:00
Jeppe Bundgaard 497ef1496b Add subuser permission evaluation system and extend subuser-related route handling
- Introduce `hasPermission` method in `subusers_o` for permission checks tied to customer context.
- Update `/subusers/me` route to return subuser grants with normalized permissions and metadata.
- Add `get_subuser_customer_number_target` in `authentication` to resolve customer context from request headers.
- Refactor route-level permission checks to handle subuser grants dynamically.
- Introduce CLI test scripts for subuser grants and permission node mappings.
- Add test coverage for subuser grants and permission nodes in new test classes.
2026-02-12 15:29:43 +01:00
Jeppe Bundgaard 6375bc7f12 Add explicit fail condition for subuser node key in route permissions
- Ensure permissions pass only if an explicit subuser node key is granted.
- Prevent fallback to classic user permissions in this authentication branch.
2026-02-12 14:28:36 +01:00
Jeppe Bundgaard f2244f5d0d Initialize permission node containers and handle uninitialized properties in subuser_user_grant to ensure proper grant resolution logic. 2026-02-12 14:08:01 +01:00
Jeppe Bundgaard 953067cba5 Extend subuser session handling and refactor permissions in order booking routes
- Add token creation for subusers in `subusers_o` during session generation.
- Refactor `orderBookingRoute` to use dynamic subuser permission definitions with `subusers_permission_node_key`.
2026-02-12 14:01:05 +01:00
Jeppe Bundgaard d26b94de3b Integrate subuser permission node system and refactor route-level permissions
- Add `permission_node` DTO to link classic permissions with subuser-specific nodes.
- Extend `authentication` to support subuser resolution via tokens.
- Introduce route traits for permission evaluation with subuser context.
- Update `requirePermission` and `hasPermission` to handle subuser grants dynamically.
- Implement fallback mechanisms for customer number context in subuser permissions.
2026-02-12 13:54:28 +01:00
Jeppe Bundgaard 2159cd293c Extend type property in tokens_o to support AUTH_TOKEN_SUBUSER 2026-02-12 13:40:19 +01:00
Jeppe Bundgaard 0fddaa79a7 Add name field to /subusers/grants response for improved subuser data clarity
- Retrieve and include the `name` field from the `subusers_o` object in the grant response.
2026-02-12 13:35:47 +01:00
Jeppe Bundgaard 62a7f8d259 Handle bool and json types in object_property and normalize permissions in subuser_grants_o
- Add support for `bool` and `json` types when updating database values in `object_property`.
- Normalize `permissions` handling in `subuser_grants_o` to ensure consistent API output for array data.
2026-02-12 13:19:57 +01:00
Jeppe Bundgaard dcf4252218 Refactor /subusers/grants update logic and require explicit autoloading for subuser module
- Replace route method for updating grants (`PATCH` to `PUT`) and streamline grant updates by directly modifying object properties instead of using manual data arrays.
- Introduce parameter validation for consistency and permission checks for cross-customer grant management.
- Require autoloading for all subuser module components (interfaces, traits, helpers, classes, and permissions) to improve modularity and maintainability.
2026-02-12 13:17:10 +01:00
Jeppe Bundgaard e9e0b3e19e Add include_non_enabled parameter to /subusers endpoint
- Allow listing subusers with only non-enabled grants by introducing an optional `include_non_enabled` query parameter.
- Update SQL query logic to conditionally include non-enabled subuser grants.
- Extend OpenAPI documentation to reflect the new parameter with its description and schema.
2026-02-11 17:58:55 +01:00
Jeppe Bundgaard 34ea4937e0 Add /subusers and /subusers/{id} endpoints for subuser management with permission-based visibility
- Implement routes to list and retrieve subusers based on grant visibility tied to the authenticated user's customer number.
- Extend OpenAPI documentation with detailed descriptions, parameters, and response schemas for the new endpoints.
2026-02-11 17:56:59 +01:00
Jeppe Bundgaard 6b90fe8d8e Refactor /subusers/grants to use paginated response and update dependencies
- Replace manual grant data processing with `listObjectsWithPaginationIfSet` for cleaner pagination and mapping logic.
- Include `subusers_permission_node_key` helper in dependencies.
2026-02-11 17:50:43 +01:00
Jeppe Bundgaard 59040b9cee Add session-based customer number fallback for subuser filtering
- Update `/subusers` route to check the current session user's `customer_number` when no filter is provided.
2026-02-11 17:44:49 +01:00
Jeppe Bundgaard 89b8587dfc Update OpenAPI documentation with new API structure and subuser registration flow
- Add detailed API info, authentication methods, and permission requirements.
- Introduce comprehensive tags for endpoints covering key modules such as Users, Orders, Bookings, Payments, and more.
- Define `/subusers` endpoint for creating subuser registrations with CVR validation and SMS setup flow.
- Update schemas for user and subuser properties, including notifications and timestamps.
2026-02-11 17:39:36 +01:00
Jeppe Bundgaard 354ad86de3 Add CRUD operations for subuser grants and list permission nodes
- Implement routes for managing subuser grants: listing, creating, updating, and deleting.
- Add endpoint to fetch available permission nodes grouped by type.
- Extend `subuser_grants_o` with new utility methods, including `asArray`.
- Update OpenAPI documentation to include new endpoints and schemas.
2026-02-11 17:25:53 +01:00
Jeppe Bundgaard a4f71261d9 Update subuser_grants_o to use default permissions and remove hardcoded driver permission
- Define `defaultPermissions` constant in `subuser_grants_o` for managing default subuser permissions.
- Adjust `add` method to use `defaultPermissions` instead of a hardcoded array.
- Update `/subusers` route to reflect this change.
2026-02-11 17:16:17 +01:00
Jeppe Bundgaard c83b7d49e4 Add permission node system and extend subuser grants functionality
- Introduce a comprehensive permission system for subusers, including permission nodes and types with support for vehicles, bookings, orders, subusers, and self-serve modules.
- Implement `subusers_user`, `subuser_user_grant`, and `subusers_permission_node` classes for managing subuser permissions and grants.
- Extend `subuser_grants_o` with methods to retrieve permissions for subusers linked to customers.
- Add traits and enumerations to streamline permission handling across modules.
- Update subuser session handling to include token-based subuser lookups.
2026-02-11 17:13:25 +01:00
Jeppe Bundgaard 6ad28a26eb Add passkeysRoute for managing user passkeys and extend OpenAPI documentation
- Introduce `passkeysRoute` with operations to list, create, rename, and delete passkeys for authenticated users.
- Update OpenAPI with endpoints and request/response schemas for passkey management.
2026-02-11 15:59:10 +01:00
Jeppe Bundgaard a37e01f7f3 Update passkeys_o timestamps to use timestamp type instead of string 2026-02-11 15:47:41 +01:00
Jeppe Bundgaard fa5a4bf1bf Add passkeys_o class for managing passkey records in the database
- Define object properties for passkey details (credential ID, public key, algorithm, etc.).
- Implement `add` method for creating passkey entries with validation and JSON encoding.
- Include database table structure and property setup within the class.
2026-02-11 15:47:20 +01:00
Jeppe Bundgaard 54de81269b Add /subusers/auth/password endpoint for subuser authentication using password and identifier types 2026-02-11 14:57:46 +01:00
Jeppe Bundgaard 0f5156cdac Add subuser authentication via password and session generation
- Add `/subusers/auth/password` route for subuser authentication using password or other username types (phone, ID, etc.).
- Implement `getSubuserByUsername` in `subusers_o` for retrieving subusers by username.
- Introduce `generateSession` in `subusers_o` for creating and caching session tokens with expiration logic.
2026-02-11 14:51:17 +01:00
Jeppe Bundgaard 937c1d7af5 Add token invalidation and improve email validation in subuser setup flow
- Introduce `invalidateSetupToken` method in `subusers_o` to invalidate setup tokens after registration completion.
- Replace regex with `filter_var` for stricter email format validation.
- Update registration link domain from `web.truckwash.dk` to `truckwash.io`.
2026-02-11 14:40:09 +01:00
Jeppe Bundgaard 66a008fc73 Add subuser_grants_o class and integrate subuser grant creation into /subusers route
- Introduce `subuser_grants_o` for managing subuser grant records in the database.
- Add logic to `/subusers` route for creating grant entries upon subuser creation.
2026-02-10 16:35:50 +01:00
Jeppe Bundgaard aae4139fea Update registration link and success message for subuser setup
- Change the registration link domain from `truckwash.io` to `web.truckwash.dk`.
- Update the response message to indicate successful setup completion.
2026-02-10 16:24:41 +01:00
Jeppe Bundgaard 2206a3dc46 Extend OpenAPI with subuser registration and setup endpoints
- Add `/subusers` route for subuser creation using CVR and phone validation.
- Introduce `/subusers/setup` with token validation and subuser setup completion.
- Define detailed request/response schemas for both endpoints.
2026-02-10 16:21:55 +01:00
Jeppe Bundgaard 9862a1856e Add subuser management route and token-based setup flow
- Introduce `/subusers` route for creating subusers and linking them to companies via phone number validation.
- Add token-based subuser setup flow including token generation, validation, and expiration handling.
- Extend `subusers_o` with methods for subuser lookup, token handling, and secure password management.
- Implement enhanced input validation for subuser creation, ensuring stricter checks for name, username, and email fields.
2026-02-10 16:20:02 +01:00
Jeppe Bundgaard 130cacddaf Add password management methods to subusers_o
- Introduce `setPassword` method for securely updating subuser passwords with validation and hashing.
- Enhance `add` method with stricter password validation and error handling.
- Refactor exception handling and standardize imports for improved clarity.
2026-02-10 14:07:11 +01:00
Jeppe Bundgaard 9e21212785 Add subusers_o class for managing subusers in the database
- Define object properties for subuser details (username, password, email, etc.).
- Implement methods for adding subuser records with validation and password hashing.
- Include database table structure and property setup within the class.
2026-02-10 14:05:31 +01:00
Jeppe Bundgaard 330ac4370f Add getWashesInTimeRange method to orders_o for fetching orders within specified daily time range
- Introduce filtering by time range and optional department ID.
- Validate inputs and ensure robust exception handling for invalid ranges.
- Optimize SQL queries for performance with joins and distinct order retrieval.
2026-02-10 14:05:22 +01:00
Jeppe Bundgaard ed1751ec2c Comment out administration fee enforcement in collected_order_invoices_o for debugging purposes. 2026-02-10 12:36:53 +01:00
Jeppe Bundgaard 8a5a7294ab Refactor invoice comparison logic and deprecate temporary route
- Enhance `/collected-invoices/economic/compare` with improved HTTP status determination and response structure.
- Add handling for `draft_total` and `booked_total` comparisons against internal totals.
- Deprecate `/tmp-customer-list-overcharged` route with error response.
- Update OpenAPI documentation for `compareCollectedInvoiceEconomic` endpoint.
- Introduce `CollectedInvoiceEconomicCompareResponse` schema for consistent API responses.
- Comment out unused return data and debug code for clarity.
2026-02-03 15:08:21 +01:00
Jeppe Bundgaard 58a5f5a26a Add route to compare collected order invoices with E-Conomic
- Introduce `/collected-invoices/economic/compare` endpoint for superusers.
- Enable validation and comparison of draft and booked invoice totals from E-Conomic against internal data.
- Add detailed error handling and warnings for mismatches and retrieval failures.
2026-02-03 12:19:56 +01:00
Jeppe Bundgaard 5aa575268f Add booked invoice helper and retrieval methods
- Introduce `economic_invoice_booked` helper for normalizing booked invoice data.
- Add `getFromId` method to fetch booked invoice details by ID.
- Extend `economic` class with `getInvoiceBookedFromExternalId` for external ID-based retrieval.
- Update imports and economic helper class registrations to include booked invoice functionality.
2026-02-03 12:19:42 +01:00
Jeppe Bundgaard ab93866295 Add Redis connection checks and optimize caching for collected order invoices
- Enhance Redis methods (`exists`, `setEx`, `delete`, `get`, `set`) to ensure connection before execution.
- Introduce short-lived caching for collected order invoices to minimize redundant processing and improve performance.
- Add `pagination_helper` for dynamic WHERE clause construction in queries.
- Refactor net amount calculation in `collected_order_invoices_o` for efficiency with batch processing.
- Extend `listObjectsWithPaginationIfSet` to support additional WHERE clauses.
2026-02-03 11:43:56 +01:00
Jeppe Bundgaard 7aa397acda Add historical invoicing endpoint and enhance permission checks
- Introduce `/superuser/invoicing/period/distribution/wash-subscriptions/historical` endpoint to retrieve historical subscription orders with detailed processing, filtering, and summary calculations.
- Reinstate permission checks for invoicing period distribution endpoints.
- Add Slack notifications for subscription price distribution summaries.
- Refine department ID handling by excluding automatic department (ID 10) during processing.
2026-02-03 09:24:58 +01:00
Jeppe Bundgaard c6cbdea3ee Add getObjectsWhereClause method to db_object_t with deprecation notice
- Introduce `getObjectsWhereClause` for fetching objects using custom where clauses.
- Mark the method as deprecated due to its vulnerability to SQL injection; recommend safer alternatives (`getFieldsWhere`, `getFieldsWhereIn`).
2026-02-03 09:24:07 +01:00