I have put the below method on the Auth
service and get the currentUserIdToken
and store it as a global variable. Is this approach has any issues? i.e. will it expire this token quickly or something like that? Or do I need to get this each and every time from the Firebase? I have done this kind of approach since I can avoid unnecessary calls to the db. Any thoughts?
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;
});
}