0

成功登录后,我需要将用户重定向到他们来自的路由。正如我所读到AuthRedirectService的,这是为此而构建的,但是当我进入产品详细信息然后点击登录并成功登录时,它只是将我重定向到根页面而不是产品详细信息页面。但它适用于应用程序中的其他页面。任何人都可以帮助我吗?谢谢

4

2 回答 2

0

Spartacus 中的重定向 URL 由NotAuthGuard, 默认情况下在 ReturningCustomerLoginComponent CMS 组件上配置。也许您有一个自定义版本的登录组件并且没有配置这个守卫?

您可以从以下指针遵循默认代码: https ://github.com/SAP/spartacus/blob/develop/projects/storefrontlib/src/cms-components/user/login-form/login-form.module.ts https://github.com/SAP/spartacus/blob/develop/projects/core/src/auth/guards/not-auth.guard.ts https://github.com/SAP/spartacus/blob/develop/projects /core/src/auth/guards/auth-redirect.service.ts#L59

于 2020-08-02T15:46:38.857 回答
0

保护 CMS 页面的推荐方法是为出现在此页面中的任何 CMS 组件配置防护。例如,您可以通过配置AuthGuardfor ProdcutIntroComponent(可能仅出现在 PDP 中)来保护产品详细信息页面,即在您的app.module

import { ConfigModule, AuthGuard } from '@spartacus/core';
/*...*/

  imports: [
    ConfigModule.withConfig({
      cmsComponents: {
        ProductIntroComponent: {
          guards: [AuthGuard]
        },
      },
    }),
  ],

无需自定义或触摸AuthRedirectService

于 2020-07-27T14:42:55.750 回答