Commit Graph
67 Commits
Author SHA1 Message Date
Jeppe B 1e0e051775 Harden Sæby demo registration and department scope (#335)
Complete and secure public customer/driver registration, authoritative limited-backoffice department scope, one-time employee QR login, and pricing concurrency for the Sæby demo.
2026-08-02 11:50:56 +02:00
Jeppe B 0060fb45ca Add in-app account deletion (#319)
## Summary
- Add self-service deletion for the authenticated customer or subuser
identity only.
- Preserve shared customer grants, reset keys, bookings, order bookings,
vehicles, invoices, and legally required history.
- Require password/TOTP or a fresh deletion-specific, five-minute,
single-use WebAuthn assertion.
- Reject support impersonation and expired legacy plain-session tokens.
- Use durable database throttling, transactional request processing, a
durable outbox, and terminal `manual_review` state.
- Keep API and worker default-off behind separate
`account_deletion.api_enabled` and `account_deletion.worker_enabled`
module-config flags.

## Safe rollout
1. Keep both flags disabled.
2. Run `php scripts/account-deletion-schema.php check`.
3. If needed, run `php scripts/account-deletion-schema.php apply --yes`,
then rerun `check` until `ready:true`.
4. Deploy the frontend companion PR while the API remains disabled.
5. Enable `api_enabled` for a controlled canary; verify password and
passwordless request flows plus immediate authentication revocation.
6. Inspect queued request/outbox state, then enable `worker_enabled`.
7. Verify anonymization, preserved tenant/history data, outbox delivery,
retries, and manual-review behavior before broad rollout.

## Verification
- Account deletion unit tests: 2 passed, 43 assertions.
- PHP lint, both OpenAPI YAML parses, runtime-DDL scan,
destructive-scope scan, and `git diff --check` passed.
- Full API/unit/integration evidence is required from exact-head CI;
local Docker is unavailable and shared-vendor tests were explicitly
discarded.

## Security notes
- Schema mutation is CLI-only; web and cron paths perform read-only
readiness checks.
- Runtime behavior fails closed when schema/config/throttle/delivery
prerequisites are unavailable.
2026-07-22 19:22:17 +02:00
Jeppe B fefe18a719 Fix legacy customer attribute session query 2026-07-16 12:20:20 +02:00
Jeppe B e1fb79d9b6 Add customer rule product restrictions 2026-07-16 11:50:52 +02:00
Jeppe Bundgaard 172a21c517 Implement department-specific customer pricing functionality 2026-07-07 17:27:56 +02:00
Jeppe Bundgaard e0ae74bdc2 Merge remote-tracking branch 'origin/master' into codex/customer-product-fixed-price-overrides 2026-07-06 17:00:52 +02:00
Jeppe Bundgaard 08dc803b3e Make limited backoffice employees regular employees 2026-07-06 16:59:32 +02:00
Jeppe Bundgaard f02dfd8c9c Add customer product fixed price overrides 2026-07-06 12:52:33 +02:00
Jeppe Bundgaard 19cacebaa1 Fix register CVR welcome email rendering 2026-06-11 21:01:34 +02:00
Jeppe Bundgaard d06c78119b Fix customer registration duplicate recovery 2026-06-11 12:04:56 +02:00
Jeppe Bundgaard bedbf21c29 Add superuser new customer email notification preferences 2026-06-08 12:20:07 +02:00
Jeppe Bundgaard 6c40810caf Add unit tests for invoicing period pagination, normalization, and filtering logic
- Implemented `InvoicingPeriodPaginationTest` for testing period pagination modes, normalization of options, search functionality, and visibility filters.
- Added comprehensive tests to validate scenarios such as active period views, exact counts, and customer-card level search.
- Improved cURL timeout settings with `CURLOPT_CONNECTTIMEOUT` and `CURLOPT_TIMEOUT` adjustments.
- Introduced and documented helper classes/methods for local caching, pagination response structure, and customer name retrieval.
2026-05-12 03:37:47 +02:00
Jeppe Bundgaard 70080086da Add unit tests for Redis namespace safety, MotorAPI cache functionality, and configuration classes, alongside implementation of xlvask_automation_service
- Added tests to ensure Redis namespace safety for `db_object_t` and `users_o`.
- Implemented `MotorApiCachedResultTest` to validate metadata caching behavior.
- Introduced configuration classes for `xlvask_automatic_order_attachment_enabled` and `xlvask_automatic_order_creation_enabled`.
- Developed `xlvask_automation_service` with supporting features for usage log evaluation, suggestion building, and order automation.
2026-05-12 00:22:27 +02:00
Jeppe Bundgaard bea7e5697b Handle empty inputs in Redis and database operations, improve safety seal validation, and enhance related tests
- Return empty arrays for empty inputs in Redis `mget`, `db_object_t`, and `users_o` operations.
- Refactor safety seal validation logic to handle numeric strings and improve clarity.
- Add unit and API tests to verify handling of empty inputs and numeric safety seal strings.
2026-05-11 04:36:11 +02:00
Jeppe Bundgaard ebe1299089 Fix PHP unit test isolation 2026-04-24 20:17:01 +02:00
Jeppe Bundgaard 9cfb19a3ba Replace CI PHP suite execution script with Composer commands and integrate Edge Gateway Agent stack artifacts 2026-04-22 12:03:08 +02:00
Jeppe Bundgaard 0b18433fdf Add unit tests for EconomicCustomerModel parsing and validation 2026-04-21 15:07:41 +02:00
Jeppe Bundgaard 551161b692 Add unit tests for Bird webhook lifecycle, economic customer handling, and payment terms routes with improved error scenarios and response validation. Refactor configuration to support economic API fallback tokens. 2026-04-01 17:44:25 +02:00
Jeppe Bundgaard 6fdc8d466e Add unit tests for various modules: attachments grouping, department weather caching behaviors, economic module order sanitization, enriched order batching, and user cashier name lookups. Update related route logic for enhanced data fetching and caching integrations. 2026-03-24 14:59:16 +01:00
Jeppe Bundgaard a22a3f4ee9 Add comprehensive unit tests for invoicing period cache logic, system search behavior, and OpenAPI spec coverage. Expand search service with generic entity support and refine association type handling. 2026-03-12 21:21:14 +01:00
Jeppe Bundgaard 1190290899 Strengthen SQL injection safeguards across objects and traits, add input validation and sanitization, and refine query efficiency with deduplication and null checks. 2026-03-12 20:36:08 +01:00
Jeppe Bundgaard ddc45bf206 Update getCustomersWithVehicleSubscriptions to exclude fixed pricing customers and remove unused return statement in invoicing route 2026-03-12 12:17:52 +01:00
Jeppe Bundgaard e143f084e4 Remove language pack logic and introduce Redis caching for customer-user mapping.
- Removed all language pack-related files, traits, and classes.
- Enhanced `users_o.php` with Redis caching for mapping `customer_number` to `user_id` and vice versa.
- Added Redis checks and caching for improved performance in user retrieval methods.
2026-02-24 12:44:43 +01:00
Jeppe Bundgaard f1c0ea2228 Remove language pack management and associated logic; add detailed logging for backups and cron processes. 2026-02-24 12:36:41 +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 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 da9ee98fb5 Add password reset request endpoint to authentication routes; update OpenAPI spec and improve user email handling in users_o 2026-01-19 11:17:35 +01:00
Jeppe Bundgaard 6cc5344fc2 Refactor department-level permission checks and enhance handling of empty department filters across routes and related object methods. 2026-01-15 11:28:44 +01:00
Jeppe Bundgaard 0eddf69ae4 Replace getCustomerByIdOrCustomerNumber with getUserByCustomerNumber across services and remove deprecated method. 2026-01-06 15:50:59 +01:00
Jeppe Bundgaard 8302b05028 Add cashier name retrieval and caching logic to orders processing
- Introduced `getCashierName` method in `users_o` for cashier name retrieval.
- Added caching for cashier names with dedicated expiration settings.
- Updated `ordersRoute` to include cashier names in order details.
- Added `$cashierNameCacheExpiration` property in `db_object_t` for centralized cache control.
2025-11-27 15:08:07 +01:00
Jeppe Bundgaard ecd44a455a - Add Redis mget method and cache management improvements
- Update cache expiration times for `economicCustomerName` and `isBooked` objects
- Introduce `getCachedForMultipleObjects` for batch cache retrieval
- Optimize `isBooked` with optional caching and update to store results
- Implement `getCustomerNames` in `users_o` with caching for bulk name retrieval
- Refactor customer transaction handling in `InvoicingPeriodRoute` for efficiency
- Filter orders excluded from invoicing in `collected_order_invoices_o`
2025-11-26 10:01:24 +01:00
Jeppe Bundgaard 8b2aa76070 Add methods to handle user notification preferences and update booking notification logic
- Introduced `wantsSmsNotifications`, `wantsEmailNotifications`, and `getWashCertificateEmail` methods in `users_o`.
- Updated `order_bookings_o` to incorporate user notification preferences for sending SMS and email confirmations.
2025-11-11 14:48:32 +01:00
Jeppe Bundgaard eca3b79f26 Add userNotificationsRoute to manage user notification settings
- Introduced new endpoint to update user notification preferences (email, SMS, wash certificate notifications).
- Enhanced `users_o` with new properties: `sms_notifications_enabled`, `email_notifications_enabled`, and `wash_certificate_email`.
- Added methods to set notification preferences in `users_o`.
2025-11-11 14:34:29 +01:00
Jeppe Bundgaard ccb049519c Add support for customer booking notifications and phone number updates
- Introduced phone number update functionality in `userSecurityRoute`.
- Enhanced `order_bookings_o` to send booking confirmations to customers via SMS and email.
- Added `sendOrderBookingConfirmationEmail` method in `email` for HTML-based email notifications.
- Updated `notifyNewBooking` to include customer confirmation logic with SMS and email.
- Adjusted `users_o` to make phone and email properties public and added `setPhoneNumber` method.
- Optimized notification logic in `order_bookings_o` with department and customer-specific notifications.
2025-11-11 13:24:32 +01:00
Jeppe Bundgaard dbc96fd0b4 Remove attribute for all associated customers if customer number exists; prevent re-adding exception in invoice collection logic. 2025-11-04 10:29:34 +01:00
Jeppe Bundgaard 30b94e89d7 Add PO number support and enhance permissions for order management
- Introduced `po` property in `orders_o` for handling Purchase Order (PO) numbers, including API integration for retrieval and validation.
- Enhanced customer permissions to allow limited order editing (`po` updates) and attachment downloads for their own orders.
- Added new helper methods to `users_o` for attributes like `showPricesOnBookingPage` and `usePONumbers`.
- Improved order item listing logic with distinct permissions for customers' own orders and price visibility.
- Implemented numeric value casting in filters within `db_object_t`.
2025-10-22 11:38:35 +02:00
Jeppe Bundgaard 6f68713c7a Comment out invoiceAllOrdersIndividually attribute initialization in users_o 2025-10-08 12:53:15 +02:00
Jeppe Bundgaard c6713f6865 Return newly added customer note as array in API response
- Updated `addNote` in `users_o` to return the `customer_notes_o` object.
- Modified `customerNotes` endpoint to include note details in the success response.
- Introduced `asArray` method in `customer_notes_o` for structured API responses.
2025-10-07 23:41:57 +02:00
Jeppe Bundgaard ed8a6454a6 Introduce subscription fallback mechanisms for vehicles with no transactions
- Added `attemptSubscriptionFallbacks` method in `InvoicingPeriodRoute` to handle vehicle subscription fallbacks through department-based strategies.
- Enhanced `customer_vehicles_o` with `getLastTransactions` for retrieving recent transactions.
- Updated `users_o` to support nullable return type for `getDefaultDepartment`.
2025-10-01 15:30:56 +02:00
Jeppe Bundgaard 69625c4fe3 Ensure requireSelected is called in getEconomicCustomerDiscountPercentage 2025-09-30 15:55:04 +02:00
Jeppe Bundgaard f5ba9dd891 Add product discount calculation and update handling for dynamic usage logs
- Introduced `getProductDiscountPercentage` method to calculate accurate discounts for users across products, categories, and global settings.
- Adjusted `importUsageLogs` to refine date modifier parameter and enhance `usage log` checks.
- Enhanced `orders_o` to include product discount logic with stricter type casting for consistency.
- Added `updateFieldsWhere` method for selective database updates based on specific conditions.
- Updated `customers_o` to handle updates for existing customers while adding new ones.
2025-07-23 09:31:43 +02:00
Jeppe Bundgaard 16198f49e6 Refactor XL Vask module for better null handling and primary item validation
- Improved null safety by updating product ID retrieval logic in parsers and usage logs.
- Enhanced primary wash item selection with stricter checks for valid product types.
- Adjusted import date modifier in `importUsageLogs` for extended range (`-7 day`).
- Streamlined product and user association in order creation with additional validations.
- Removed redundant checks and refined permission handling in import tasks.
2025-07-21 16:47:05 +02:00
Jepp9350 6b80637208 Refactor InvoicingPeriodRoute and vehiclesRoute: streamline invoicing period data retrieval, enhance transaction handling across customer types, introduce new methods for efficient object construction, and add improved type validation in object_property. 2025-06-30 14:37:37 +02:00
Jepp9350 c5a6b2006f Add methods for retrieving customers and transactions within date ranges, enhance orders_o functionality, and improve customer object construction in invoicing routes. 2025-06-26 16:06:02 +02:00
Jepp9350 6e6ab047ec Add XLVask customer creation logic, extend user and helper classes, and integrate Slack notifications for failed API requests. 2025-06-17 12:24:14 +02:00
Jepp9350 0e82d9a7bf Add customer synchronization support in xlvask with caching, filtering, and external ID handling 2025-06-03 13:52:23 +02:00
Jepp9350 9774b589cc Add handling for fixed pricing and tank cleaning transactions with action checks and enhanced customer retrieval 2025-06-02 22:04:57 +02:00
Jepp9350 27ca81ba8f Add support for invoicing period retrieval and enhanced filtering options for wash subscription transactions 2025-06-02 14:08:57 +02:00
Jepp9350 743928459e Add customer default department handling and routes 2025-05-26 16:58:09 +02:00
Jepp9350 a45e2706c3 Refactor customer number handling for clarity.
Reassign the customer number to a variable before reuse, improving code readability and reducing redundant calls to the value method. This change streamlines object property creation and simplifies maintainability.
2025-05-20 14:05:47 +02:00