Darren
Darren

Reputation: 1

Redirect to a page after authentication

After authenticating a user, how can I redirect them to a dashboard. How would it be customized with information about each user, and not information hard-coded onto a page? How does this relate, if at all, to getRedirectResult? Thanks.

Upvotes: 0

Views: 214

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598765

You'll typically listen to onAuthStateChanged() for that. Whenever the user authentication state changes, your handler will get called and you can act on the new state. E.g.

firebase.auth().onAuthStateChanged(function(user) {
  if (user) {
    // User is signed in so redirect to dashboard
  } else {
    // No user is signed in, so show login page
  }
});

Upvotes: 1

Related Questions