angular - Do I need an Angularfire2 Authentication Service? -


i working on project angular 4 , firebase.

currently, in every component needs access firebase authentication, add constructor. however, takes bit realize user logged in when loads.

for single-page application, isn't of problem, however, using routing, every time switch page, new component has loaded scratch.

would making service handle authentication in background solve issue?

two things:

  1. your authentication should done in service (logging in, logging out, checking auth state, etc.)
  2. you should setup guards prevent routes being accessed unless specific criteria met (ie, user logged in).

https://angular.io/api/router/canactivate


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -