【发布时间】:2018-02-08 08:46:24
【问题描述】:
在我的 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);”
签名.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 响应为:
firebase images
我需要您的帮助来解决一些 facebook 帐户与 firebase 配合使用的问题。?
【问题讨论】:
-
如您所见,使用了此贡献推荐的。 :stackoverflow.com/questions/40570200/…
-
可能是 Facebook 帐户没有电子邮件。您也可以尝试在使用 Facebook 登录时请求电子邮件范围吗?
标签: facebook firebase firebase-authentication ionic3 angularfire2