angular - Angularfire2: Proper approach to check if user is logged in? -


i wan't allow logged in users access site. what's proper way of checking if user logged in on load?

the code below first try, don't know if works though. of course wrote db rules, want complete behavior visually user.

this.af.auth.subscribe(auth => {    if (auth) {       //route other view    } else {       //do whatever    } }); 

you should consider use angular 2 guards, canactivate. can validation before routing happens. way can prevent navigation of unauthorized users.

as early, approach works. if want transformation on auth information. probably, should use observables methods map, flatmap, concatmap.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -