Repository navigation
feat(customers): add rider routes with owner checks - #420
Merged
Merged
Conversation
Give a rider app what it needs on /v1/customers, limited to the rider's own records: - request-code answers the same for known and unknown numbers - verify-code reports new_customer only after the code is proven - places/search, geocode, and saving, editing and deleting places - dispatch, cancel, driver, tracker and ETA for the rider's own orders - a narrow customer socket principal Also: - Make the signup password optional - Require a code for the new number to change phone on customers/me - Refuse expired fares when a rider books - Stop fare previews storing a place per request - Treat another company's service quote as not found
Composer refuses to install illuminate/mail on Laravel 10 because of CVE-2026-48019, which has no patch before Laravel 12. Ignore this one advisory in PHP CI so the tests can run. Production dependencies don't change. Remove this when the Laravel 12 upgrade lands.
symfony/http-kernel 6.4, the only version Composer will install for Laravel 10 now, conflicts with var-dumper below 6.3. This is a dev-only dependency, and production already runs 6.4.
Cover the rider place, phone change, order and tracking routes, the customer socket principal, and another company's service quote. Update existing tests for the verify-code message and for phone changes needing a code. Check a quote's company after looking it up, so a quote from another company is refused the same way for every lookup, and move the rider place query behind a method so it can be tested.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #420 +/- ##
============================================
Coverage 100.00% 100.00%
- Complexity 13847 13947 +100
============================================
Files 642 642
Lines 49865 50099 +234
============================================
+ Hits 49865 50099 +234
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
4 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the
/v1/customersroutes a white-label rider app needs, so it no longer has to use company-wide routes. Every route is limited to the signed-in rider's own records. An order or place belonging to someone else returns 404.New routes
POST customers/request-codesends a login or signup code and answers the same for any number.verify-codereturnsnew_customeronly after the code is proven, without using the code up.GET customers/places/searchreturns the rider's places plus geocoder results. Unowned rows are excluded because they hold addresses from other riders' trips.GET customers/geocodelooks up an address or coordinates and stores nothing.POST,PUTandDELETE customers/places.POST customers/me/phone-code.POST customers/orders/{id}/dispatchandcancel, andGETdriver,trackerandeta.driverreturns name, photo, location and car, with no contact details.Behaviour changes for existing callers
customers/merefuses a phone change unless it comes with a code sent to the new number, and refuses a number another account holds. Storefront and Navigator don't use this route, but a third-party integration might.ServiceQuote::resolveFromRequesttreats another company's quote as not found.customers/ordersrefuses an expired fare or one from another company.verify-codefor an unknown identity now saysInvalid verification code.instead ofUnable to verify code..GET service-quotes?preview=1no longer stores a place for coordinates.Left unchanged
places/searchstill returns customer-owned places to a full key, because the Odoo and ERPNext clients use it. The rider key in fleetbase/core-api is what keeps a published app off this route.customers/login-with-smsstill reveals unknown numbers to older callers.The rider key profile is a separate change in core-api, and neither PR needs the other to merge first.
Testing
Pest passes on PHP 8.4 for every test file touching this code. The full suite wasn't run, and CI on this PR is the first full run.
Also run against a local API with a rider key: place isolation, saved places, previews storing nothing, cancel, tracker, ETA, two-step signup with no password, and phone changes.
Not exercised against a real API
request-code, which could text a real number (mocked tests only).driveranddispatchwith a real assigned driver.