ionic3 + firebase + angularfire2 facebook email null每个电子邮件地址有多个帐户

时间:2017-08-30 14:58:57

标签: facebook firebase firebase-authentication ionic3 angularfire2

在我的firebase信息中心中,我为一个电子邮件选项设置了多个帐户。
firebase dashboard

Angularfire2的配置是标准的,所以我没有点击app.modules.ts的代码

home.ts

facebookir(){
let goPagePrehome:boolean = false;
let userDB:any;
firebase.auth().signInWithPopup(new firebase.auth.FacebookAuthProvider())
  .then(res => {
    console.log(res);
    console.info(JSON.stringify(res));
    this.userService.getUsers()
    .forEach((users) => {
      users.forEach((user) =>{
            if(user['user_email'] == res.additionalUserInfo.profile.email){
              // console.log('res.additionalUserInfo.profile.email');
              // console.log(user);
              userDB = user;
              goPagePrehome= true;
            }
      });
      if(goPagePrehome){
        this.goNextPagePrehome(userDB);
      }else{
        this.singup();
      }
    });
  }); }

在上面的代码中,用户的电子邮件是在我们的数据库中创建和验证的。并被发送到记录“this.singup();”或者到家里“this.goNextPagePrehome(userDB);”

sign.ts

this.afAuth.authState.subscribe( user => {
    console.log('find user facebook 2');
    console.log(user);
    if (user){
      if(user.providerData["0"].providerId == "facebook.com"){
        if(this.userData['picture'] == '' || this.userData['picture'] ==  undefined || this.userData['picture']== null){ 
          console.info('find user facebook 2 - si');
          this.userData['name']=this.userData['username']= user.providerData["0"].displayName;
          this.userData['email']=  user.providerData["0"].email;
          this.userData['picture']=  user.providerData["0"].photoURL;
          console.log(this.userData);
        }
      }
      //this.envioCorreoFacebook();
    } else {
      console.info('find user facebook 2 - no');
    }
  });

正如您在两个文件中看到的那样,我正在验证提供商提供的数据的邮件为“providerData [”0“]”和“res.additionalUserInfo.profile.email”。
火力响应是:
firebase images

我需要你的帮助才能解决一些facebook账号与firebase一起使用的问题。

1 个答案:

答案 0 :(得分:0)

我又收到了邮件;虽然默认情况下它应该把它带到所有的Facebook帐户。

var provider = new firebase.auth.FacebookAuthProvider();
    provider.addScope('email');
    firebase.auth().signInWithPopup(provider)
      .then(res => {...});