fix: filter out cross-app products in cart sync - #729
Open
Hsu-Pei-Chun wants to merge 1 commit into
Open
Conversation
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.
問題描述
購物車在 sync 時,會將 localStorage 和 DB 的商品合併,但沒有驗證商品是否屬於當前 app。當
cart_product表中存在跨 app 的商品(例如cw的方案出現在demo的購物車),這些商品:_removePhaseOutCartProducts過濾掉)checkout-orderAPIE_CHECKOUT_ORDER「找不到方案」→ 整批失敗totalPrice = 0,無法結帳修改內容
在
CartOperator.syncCartProducts中新增filterByValidProductIds,利用 Hasura row-level permissions 的特性來判斷商品是否屬於當前 app:productGraphQL 查詢中加入product_owner.member.app_idproduct_owner或product_owner.member會是null(被 Hasura 權限過濾)影響範圍
src/services/cart/CartOperator.tssyncCartProducts:使用filterByValidProductIds過濾後再寫入_createGetCartProductOperationQuery:product查詢新增product_owner { member { app_id } }filterByValidProductIds函數測試方式
cart_product表中加入跨 app 的商品checkout-orderAPI 只收到有效商品的 productIds