关于SAP Spartacus重载(override)UserAuthenticationTokenService的问题
无法通过下列语句导入这个服务:
import {UserAuthenticationTokenService} from '@spartacus/core/src/auth/services/user-authentication/user-authentication-token.service';
解决办法:
While it’s true that it’s not being exported directly in Spartacus 2.x, I have found that it is still available. If you look at the compiled spartacus-core.d.ts file, you will see that UserAuthenticationTokenService is being exported under a gibberish(莫名其妙的) name:
export { UserAuthenticationTokenService as ɵbj } from './src/auth/services/user-authentication/user-authentication-token.service';
While this is probably not the best idea, I have found that you can actually import this in your own code. You can also rename it back to the original name for legibility:
import { ɵbj as UserAuthenticationTokenService } from '@spartacus/core';
I have used this myself on my current project and it seems to work fine:
@Injectable({providedIn: 'root'
})
export class MyUserAuthenticationTokenService extends UserAuthenticationTokenService {}
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MyUserAuthenticationTokenService } from './services/my-user-authentication-token.service';
import { ɵbj as UserAuthenticationTokenService } from '@spartacus/core';@NgModule({declarations: [],imports: [CommonModule,],providers: [{ provide: UserAuthenticationTokenService, useExisting: MyUserAuthenticationTokenService }]
})
export class MyAuthModule {}
If you’re using Spartacus 2.x, UserAuthenticationTokenService is present in @spartacus/core, but unfortunately it doesn’t seem to be exposed in the public api. Therefore, you won’t be able to import it.
If you’re using Spartacus 3.x, UserAuthenticationTokenService was removed. Spartacus 3.0 introduces a new session management implementation. You can learn more about it here.
关于SAP Spartacus重载(override)UserAuthenticationTokenService的问题相关推荐
- SAP Spartacus 3.0 的一些变化
SAP Spartacus 确实使用到了Bootstrap这个框架: Technical Changes in Spartacus 3.0 Breaking Changes Translations ...
- SAP Spartacus 4.0 版本因为 hamburger 依赖导致构建出错的问题
build from Schematics 遇到错误消息: SassError: Undefined function. https://github.com/SAP/spartacus/issues ...
- SAP Spartacus UI 服务器端渲染的调试启动方式 - debug 模式
首先确认你已经熟悉这篇文章的启动方式:SAP Spartacus develop branch 的服务器端渲染启动方式. 第一步 添加一个新的 build script,把 --configurati ...
- SAP Spartacus Session affinity
参见这个讨论. 后端运行在多个 pods/节点时,当子序列请求过早进入时,后端将无法跨集群发送缓存失效请求.此外,如果多个请求分散在多个节点上,则会消耗延迟和不必要的资源. 对于单个客户端,Spart ...
- SAP Spartacus 4.0 的技术变化
在您迁移到 4.0 版库之前,我们强烈建议您切换到新的应用程序结构和新的功能库. 在多个小步骤中进行迁移更容易(迁移到新的应用程序结构,切换到提取的功能库,然后迁移到 4.0),您可以确保在每一步之后 ...
- SAP Spartacus travis ci-scripts 下面 e2e-cypress.sh 的实现分析
文件地址:https://github.com/SAP/spartacus/blob/develop/.travis.yml 里面引用到了 e2e-cypress.sh: https://github ...
- SAP Spartacus 里的 .release-it.json 文件
在 SAP Spartacus package.json 里有一个依赖叫做 release-it: 这个工具的链接:https://github.com/release-it/release-it 这 ...
- SAP Spartacus PageLayoutComponent 如何知道自己应该显示哪些具体内容
我们以前介绍过,经过 SAP Spartacus 路由配置后的 routes 数组,其 route 数据结构的 Component 属性,清一色指向 generic 的 PageLayoutCompo ...
- SAP Spartacus UI Duplicated keys has been found in the config of i18n chunks
在测试 SAP Spartacus 3.4.5 版本的 SSR 功能时,发现一个 warning 信息: console.warn(`Duplicated keys has been found in ...
最新文章
- Codeforces Round #649 (Div. 2)C. Ehab and Prefix MEXs[排列的构造]
- 导出Windows服务器下的Oracle数据库并导入到Linux服务器下的Oracle数据库中
- 浅析移动端建站周期影响因素有哪些?
- JMeter性能测试的基础知识和个人理解
- JavaScript实现Floyd-Warshall算法(附完整源码)
- SpringBoot 中 @Transactional 的使用
- 今天安家 明天开始在网络的海洋里遨游
- Atitit.计算机图形图像图片处理原理与概论attilax总结
- iOs LightBlue与cc2540 BLE开发板之间的通信实验 [原创, 多图]
- c++ 远程监控软件
- 蓝天准系统P750的介绍与开箱
- FreeSWITCH ODBC cdr
- 数据库mysql表常见字段大小_常用数据库的字段类型及大小
- 基于MATLAB的光纤通信仿真
- Linux Thermal Framework分析及实施
- Android开发5年,字节腾讯惨被血虐,我真的不适合这行吗?
- Oracle_登录数据库系统
- web4.0之万能密码登录
- C51学习笔记 4.定时器
- Python psutil cpu_percent调用说明