Angularfire2: The right approach to check if a user is registered?

I do not allow only user access to a specific site. What is the correct way to verify user login at boot time?

The code below is my first attempt, I really don't know if this works. Of course, I already wrote db rules, now I want the user to visually execute the behavior.

this.af.auth.subscribe(auth => { if (auth) { //route to other view } else { //do whatever } }); 
+1
angular firebase firebase-authentication angularfire2
source share
1 answer

You should use angular 2 guards, for example canActivate . They can help you validate before routing occurs. This way you can prevent unauthorized users from navigating.

As they say before, this approach works. If you want to do the conversion via auth information. You should probably use methods like map, flatmap, concatMap.

+2
source share

All Articles