Angular 2+ Firebase Authentication - Set Login State Persistence

后端 未结 3 1028
清酒与你
清酒与你 2021-01-12 14:07

I\'ve set up authentication using firebase for an angular app in an auth service, and I\'m trying to ensure session state persistence following successful login.

I\'

3条回答
  •  没有蜡笔的小新
    2021-01-12 15:01

    It is likely you are not using onAuthStateChanged listener to detect the initial Auth state on page load.

    firebase.auth().onAuthStateChanged(user => {
      if (user) {
        // User signed in.
      } else {
        // User not signed in.
      }
    });
    

提交回复
热议问题