-
-
Save gavilanch/2048ab5f6d6958a2ebc9240beb00ab2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class AppComponent implements OnInit { | |
user: User; | |
constructor(private afAuth: AngularFireAuth, | |
private router: Router, | |
private ngZone: NgZone){} | |
ngOnInit(){ | |
this.afAuth.user.onAuthStateChanged(user => { | |
if (user){ | |
this.user = user; | |
} else{ | |
this.user = null; | |
this.ngZone.run(() => { | |
this.router.navigate(['']); | |
}) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment