【发布时间】:2020-05-04 12:32:15
【问题描述】:
我已将以下方法放在Auth 服务上并获取currentUserIdToken 并将其存储为全局变量。这种方法有问题吗?即它会很快过期这个令牌或类似的东西吗?还是我每次都需要从 Firebase 获取这个?我已经采用了这种方法,因为我可以避免对数据库的不必要调用。有什么想法吗?
init(): void {
this.afAuth.authState.subscribe(async (user: firebase.User) => {
if (user) {
this.currentUserUid = user.uid;
this.currentUserIdToken = await this.afAuth.auth.currentUser.getIdToken(true); // Here
this.onboardingService.currentUserUid = this.currentUserUid;
});
}
【问题讨论】:
标签: angular typescript firebase firebase-authentication ionic4