AngularFire2检查帐户是否存在

时间:2017-05-15 05:40:40

标签: javascript firebase ionic2 firebase-authentication angularfire2

我正在使用Ionic和AngularFire2对Firebase进行身份验证。我允许用户通过GooglePlus提供商登录并在Firebase上创建帐户。然后,如果用户退出,并尝试使用浏览器使用具有相同电子邮件地址的Facebook帐户登录,则会收到以下消息:

loginFacebookBrowser(): Promise<FirebaseAuthState> {
    return new Promise<FirebaseAuthState>((resolve) => {
        this.af.auth.login({ provider: AuthProviders.Facebook, method: AuthMethods.Popup }).then((success: FirebaseAuthState) => {
            resolve(success);
        }).catch((error) => {
            this.loading.dismiss();
            console.error('loginFacebook', error);
            this.doAlert('loginFacebook: ' + error.message);
        });
    });
}
  

tg {code:&#34; auth / account-exists-with-different-credential&#34;,message:   &#34;已存在与提供商使用相同电子邮件地址的帐户   与此电子邮件地址相关联。&#34;,电子邮件:&#34; xxxxxxxx@gmail.com",   凭证:Uf,__ zone_symbol__currentTask:t}

如果我使用AngularFire cordova插件并尝试在 Android设备上登录,它只会挂起而没有错误消息。

loginFacebookCordova(): Promise<FirebaseAuthState> {
    return new Promise<FirebaseAuthState>((resolve) => {
        Facebook.login(['public_profile', 'email']).then(facebookData => {
            let cred: firebase.auth.AuthCredential = firebase.auth.FacebookAuthProvider.credential(facebookData.authResponse.accessToken);
            firebase.auth().signInWithCredential(cred).then((data: FirebaseAuthState) => {
                resolve(data);
            });
        }, error => {
            this.loading.dismiss();
            console.error('loginFacebook: ' + error);
            this.doAlert('loginFacebook: ' + error.message);
        });
    });
}

问题

如何让Cordova插件具有与浏览器相同的行为,并向用户显示有意义的消息?或者,如果无法做到这一点,是否可以检查帐户(电子邮件地址)是否已存在于不同的提供商处?

的package.json

"angularfire2": "^2.0.0-beta.8",
"firebase": "^3.7.5",

0 个答案:

没有答案
相关问题