简体   繁体   English

Firebase登录-如何重置uid?

[英]Firebase Login - How to reset uid?

I am using Ionic2 rc4, and Firebase Authentication. 我正在使用Ionic2 rc4和Firebase身份验证。 If I call signupFirebaseUser() , it logs a uid as expected. 如果我调用signupFirebaseUser() ,它将按预期记录一个uid However, when I then call loginGoogle() , I would expect it to log a different uid , but it prints the same uid . 但是,当我随后调用loginGoogle() ,我希望它记录一个不同的uid ,但是它将输出相同的uid

This means that a user cannot log in with an email address and password , log out, and then re log in with their Google account (different email address) because it wants to retain their old uid . 这意味着用户无法使用email addresspassword ,注销,然后使用其Google帐户(不同的电子邮件地址)重新登录,因为该用户想要保留其旧的uid

signupFirebaseUser(email: string, password: string): firebase.Promise<any> {
    return this.fireAuth.createUserWithEmailAndPassword(email, password).then((newUser: firebase.User) => {
        console.log(newUser.uid);
        this.userProfile.child(newUser.uid).set({ email: email });
        newUser.sendEmailVerification();
    });
}

then 然后

public logout(auth: FirebaseAuth, fireAuth: firebase.auth.Auth): Promise<any> {
        return auth.logout().then(() => {
            fireAuth.signOut().then(() => {
            });
        });
}

then 然后

  loginGoogle() {
    this.auth.login({
      provider: AuthProviders.Google,
      method: AuthMethods.Popup
    }).then((data: FirebaseAuthState) => {
        console.log(data.uid);
    }).catch((error) => {
      console.error('loginGoogle', error);
    });
  }

Question

How do you reset the Firebase Authentication to forget the old uid ? 如何重置Firebase身份验证以忘记旧的uid So that when you log in again, you do so from a clean start. 这样,当您再次登录时,便会从头开始。

ie Generate a new uid for each provider (Google, Facebook, Email). 即为每个提供商(Google,Facebook,电子邮件)生成一个新的uid

Any help appreciated. 任何帮助表示赞赏。

You most likely have the option on which ensures you can only have one account per email address (this is actually the default if I remember correctly). 您最有可能选择该选项,以确保每个电子邮件地址只能拥有一个帐户(如果我没有记错的话,这实际上是默认设置)。 To change this option, head to https://console.firebase.google.com/project/_/authentication/providers , select your Firebase project, scroll down to "Advanced" section, and hit the "Change" button next to "One account per email address." 要更改此选项,请转到https://console.firebase.google.com/project/_/authentication/providers ,选择您的Firebase项目,向下滚动到“高级”部分,然后点击“每个电子邮件地址一个帐户。” There you can set how to handle accounts for the same email address and turn off this behavior. 您可以在此处设置如何处理同一电子邮件地址的帐户,并关闭此行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM