getUser starts always with undefined in angular SKD 9

Hi there,
I followed the tutorial to set up authentication for angular 9. Now, I want to redirect to login page the user immediately if not logged, what I do is simply

export class AppComponent implements OnInit {

constructor(public auth: AuthService) {
}

ngOnInit(): void {
this.auth.getUser$().subscribe((c) => {
console.log(‘result user getuser’ + c)
if (c == undefined)
this.auth.login()
})
}

}

The problem is that the first user that is streamed is always undefined, afterwards, if the user is actually logged, the real user is returned, causing the reload of the component and breaking my system.
Moreover, I noticed that reloading a page where I am authenticated in incognito mode, it causes the service to forget the authentication.
Any solutions? Thank you

Hey there!

Can you let us know what doc/ quickstart do you follow?

Hi Konrad, sure!
https://auth0.com/docs/quickstart/spa/angular2/01-login
this one

I am also getting undefined for user.

Can you guys raise this as a GitHub issue in our Angular SDK GitHub repo so we can work on that directly with the repo maintainers and solve that hurdle most effectively? Thanks! Make sure to share link to the issue here in the thread.

Do you have the link to the GitHub issue? I have a problem where the getUser call returns undefined when the application reloads.
@angular/cli”: “~14.2.6”,
@auth0/auth0-angular”: “~1.11.0”