How to get currently logged in auth state/user from angularfire2

前端 未结 4 1423
囚心锁ツ
囚心锁ツ 2021-02-05 18:55

I have an ionic2 app and am using Firebase and angularFire2. I\'d like to get the current authentication state and current auth object/user from firebase using angularFire2.

4条回答
  •  后悔当初
    2021-02-05 19:25

    now in order to get the user info, you have to subscribe for getting the auth information. Ex

      constructor(public af: AngularFire) {
        this.af.auth.subscribe(auth => console.log(auth));// user info is inside auth object
      }
    

    auth object will be null if auth state does not exist

提交回复
热议问题