Angular HttpClient + firebase-如何在页面刷新后保持记录状态

时间:2018-07-20 11:46:53

标签: angular typescript firebase

我将firebase用作angular的后台,我使用http请求与firebase进行通信,

页面刷新后,我想保留登录状态

doGoogleLogin() {
    return new Promise<any>((resolve, reject) => {
      const provider = new firebase.auth.GoogleAuthProvider();
      provider.addScope('profile');
      provider.addScope('email');
      this.afAuth.auth
        .signInWithPopup(provider)
        .then(res => {
          resolve(res);
          firebase.auth().currentUser.getIdToken().then((tok) => {
            this.token = tok;
          });
        });
    });
  }

0 个答案:

没有答案