I am encountering an issue with the code in my authService
constructor(
private afAuth: AngularFireAuth,
private db: AngularFireDatabase,
private router: Router
) {
this.authState = afAuth.authState;
this.authState.subscribe((user: firebase.User) => {
this.authState = user;
});
if ( this.authenticated ) {
// this.router.navigate([`/content`]);
}
}
// Returns true if user is logged in
get authenticated(): any {
return this.authState;
}
When I call the get authenticated
method, it returns undefined:
COMPONENT
constructor(
private auth: AuthService
) {
this.currentUser = this.auth.authenticated;
}
showUser() {
console.log(this.currentUser.uid);
}
I am looking for assistance on resolving this issue, any suggestions?