mardi 2 mai 2017

Firebase how to redirect login page when user is not authenticated

I want to setup my web page hosted by firebase so that.

  1. User requested a page that needs authentication
  2. If user is authenticated, serve the page
  3. If user is not authenticated, redirect to login page, and when login succeeds, redirect to the originally requested page

Searching for solutions, firebase.auth().onAuthStateChanged can be used to check if the user is authenticated, but there is some delay in client side (~ 1 second) which I don't want. Also, I don't know how to redirect to the requested page after successful login.

Can anybody help?

Thanks,
-Minsuk




Aucun commentaire:

Enregistrer un commentaire