前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >如何分析 SAP Spartacus 路由问题之 CheckoutAuthGuard 单步调试

如何分析 SAP Spartacus 路由问题之 CheckoutAuthGuard 单步调试

作者头像
Jerry Wang
发布2021-06-10 15:40:09
2780
发布2021-06-10 15:40:09
举报

This document is written based on Spartacus 3.1.1.

The standard Storefront is used which is generated by Spartacus Schematics.

Suppose I would like to debug the executing of CheckoutAuthGuard for standard checkout step:Delivery Mode.

It means I need to set some breakpoint in the step BEFORE Delivery Mode, in this case it is Shipping address step, and then click “Continue” button to trigger the breakpoint.

in your project, expand folder node_modules/@spartacus:

then storefront/fesm2015, find file spartacus-storefront.js:

Search by key word “CheckoutDeliveryMode”, which is the default CMS component for Delivery Mode checkout step.

You see line 11037, the two standard component guard, CheckoutAuthGuard and CartNotEmptyGuard are defined there.

Add some product to carts, then open url:

http://localhost:4200/electronics-spa/en/USD/checkout/shipping-address

open Chrome Development tool,switch to Sources tab,press Ctrl+ O,type spa, then select spartacus-storefront.js from search list:

then search by keyword CheckoutAuthGuard:

and set breakpoint in method canActivate.

Let’s say if a checkout Component has configured Component guards A,B,C, only if all guards return true intheir canActivate method, then the corresponding checkout step page could be opened.

In my case I press “continue” button in Shipping Address page, then breakpoint is triggered.

then you can debug to check the guard execution.

As mentioned by document, canActivate method is expected to return true to achieve the routing of next checkout step.

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2021-06-08 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档