Commit 0e1ccf4
fix(medusa): allow admin draft orders without an email or customer_id (#16133)
* fix(medusa): allow admin draft orders without an email or customer_id
POST /admin/draft-orders required either email or customer_id via a
validator refine(), but createOrderWorkflow and the Order data model
already tolerate neither being set. This blocked use cases with no
captured customer identity, e.g. POS/walk-in retail orders.
Raised in #15820.
* fix(medusa): don't leak an unrelated customer's email on anonymous draft orders
The customer-lookup fallback in POST /admin/draft-orders queried with
filters: { id: undefined } when customer_id was omitted, which matched
an arbitrary customer instead of none, leaking their email onto the
draft order. Only run the lookup when customer_id is provided.
Caught by the new test added in this PR.
---------
Co-authored-by: Giorgi Bregvadze <gbreg19@duck.com>1 parent 9fa4bd9 commit 0e1ccf4
4 files changed
Lines changed: 26 additions & 16 deletions
File tree
- .changeset
- integration-tests/http/__tests__/draft-order/admin
- packages/medusa/src/api/admin/draft-orders
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
211 | 226 | | |
212 | 227 | | |
213 | 228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 91 | + | |
106 | 92 | | |
107 | 93 | | |
108 | 94 | | |
| |||
0 commit comments