在spartacus中扩展AuthService时添加额外的实现



想要在注销时添加自定义逻辑。已经创建了customAuthService扩展AuthService重写注销方法,但我如何使用UserToken和authselector ?无法从@spartacus/core导入相同的

您能提供更多关于您的具体用例吗?

export class AppModule {
constructor(client: AuthService) {
client.getUserToken().subscribe((token) => console.log('user token: ', token));
client.getOccUserId().subscribe((id) => console.log('id: ', id));
client.getClientToken().subscribe((clientToken) => console.log('Client token: ', clientToken));
client.getClientToken().subscribe((clientToken) => console.log('Client token: ', clientToken));

client.isUserLoggedIn().subscribe((logged) => console.log('user logged? ', logged));
client.authorize('1', '2');
}
}

只要注入AuthService,你就可以从它的方法getUserToken中使用UserToken。

最诚挚的问候,杰瑞

最新更新