Angular Ionic 4中的Firebase Google Auth-如何检查用户是否首次登录,以便我可以将用户导航到其他页面?

Angular Ionic 4中的Firebase Google Auth-如何检查用户是否首次登录,以便我可以将用户导航到其他页面?,angular,typescript,firebase-authentication,ionic4,Angular,Typescript,Firebase Authentication,Ionic4,我有一个应用程序,你可以登录电子邮件和谷歌认证。用户可以创建一个帐户,在创建帐户后,我会引导他们创建一个显示在主页上的配置文件,以便。。。我想做的是,由于谷歌身份验证只是一个按钮,我想在用户第一次登录谷歌时检查一下,我希望他们在使用谷歌身份验证后立即创建一个配置文件,然后当他们再次尝试使用谷歌身份验证登录时,我想显示主页,以便他们可以查看自己的数据,而不是再创建一个配置文件 user: Observable<firebase.User>; constructor(private

我有一个应用程序,你可以登录电子邮件和谷歌认证。用户可以创建一个帐户,在创建帐户后,我会引导他们创建一个显示在主页上的配置文件,以便。。。我想做的是,由于谷歌身份验证只是一个按钮,我想在用户第一次登录谷歌时检查一下,我希望他们在使用谷歌身份验证后立即创建一个配置文件,然后当他们再次尝试使用谷歌身份验证登录时,我想显示主页,以便他们可以查看自己的数据,而不是再创建一个配置文件

user: Observable<firebase.User>;

  constructor(private fireAuth: AngularFireAuth,
    private toast:ToastController, 
    public navCtrl:NavController,
    private gplus: GooglePlus,
    private platform: Platform) {
      this.user = this.fireAuth.authState;
    }

    googleLogin() {
      if (this.platform.is('cordova')) {
        this.nativeGoogleLogin();
      } else {
        this.webGoogleLogin();
      }
    }
    async nativeGoogleLogin(): Promise<void> {
      try {
        const gplusUser = await this.gplus.login({
          'webClientId': '****************.apps.googleusercontent.com',
          'offline': true,
          'scopes': 'profile email'
        })
        return await this.fireAuth.auth.signInWithCredential(firebase.auth.GoogleAuthProvider.credential(gplusUser.idToken)).then(suc=>{
          this.fireAuth.authState.pipe(take(1)).subscribe(async auth => {
            if(!auth.uid){
              this.navCtrl.navigateRoot('/home');
            }
            else{this.navCtrl.navigateRoot('/profile');
            }
          })  
        }).catch(ns =>{
          alert("error")
        })

        } catch(err) {
    console.log(err)
  }
}
用户:可观察;
构造函数(私有fireAuth:AngularFireAuth,
私人吐司:吐司控制器,
公共navCtrl:NavController,
私人gplus:GooglePlus,
专用平台:平台){
this.user=this.fireAuth.authState;
}
谷歌登录{
如果(此.platform.is('cordova')){
this.nativeGoogleLogin();
}否则{
这个.webGoogleLogin();
}
}
异步NativeGogleLogin():承诺{
试一试{
const gplusUser=等待this.gplus.login({
“webClientId”:“***************.apps.googleusercontent.com”,
“离线”:对,
“范围”:“配置文件电子邮件”
})
返回等待此.fireAuth.auth.signInWithCredential(firebase.auth.GoogleAuthProvider.credential(gplusUser.idToken))。然后(suc=>{
this.fireAuth.authState.pipe(take(1)).subscribe(async auth=>{
如果(!auth.uid){
this.navCtrl.navigateRoot('/home');
}
else{this.navCtrl.navigateRoot('/profile');
}
})  
}).catch(ns=>{
警报(“错误”)
})
}捕捉(错误){
console.log(错误)
}
}

这个
nativegoglelogin()
函数的作用是,它首先显示配置文件创建页面,然后将用户导航到主页,但它总是重复此操作,所以我需要你们的帮助!我希望用户只创建一次配置文件,之后我希望他们每次都能访问主页。

您是否了解可以通过auth传递哪些自定义参数?我只是想知道你试过什么,我已经搜索过了,但是由于我在js&ts中缺乏过期性,代码无法正常工作,但是谢谢你的建议!您是否研究了可以通过auth传递哪些自定义参数?我只是想知道你试过什么,我已经搜索过了,但是由于我在js&ts中缺乏过期性,代码无法正常工作,但是谢谢你的建议!