Firebase-防止用户身份验证

Firebase-防止用户身份验证,firebase,firebase-realtime-database,firebase-authentication,Firebase,Firebase Realtime Database,Firebase Authentication,如果在allowedUsers中找不到他们的电子邮件,我需要阻止用户身份验证。它实际上并不影响应用程序,因为所有操作都将在用户列表上执行,但如果不进行身份验证,那就太好了 loginWithGoogle() { const userDetails = this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider()) .then(user => { console.log(us

如果在
allowedUsers
中找不到他们的电子邮件,我需要阻止用户身份验证。它实际上并不影响应用程序,因为所有操作都将在
用户
列表上执行,但如果不进行身份验证,那就太好了

loginWithGoogle() {
    const userDetails = this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider())
      .then(user => {
        console.log(user.user.uid);

        const queryObservable = this.db.list('/allowedUsers', {
          query: {
            orderByChild: 'email',
            equalTo: user.user.email,
          }
        }).subscribe(data => {

          if (data.length > 0) {

            const userObj = {
              admin: false,
              ...
              email: data[0].email,
              name: data[0].name,
              verified: false,
            };

            this.addUser(userObj, user.user.uid);

          }

        });

      });

    return userDetails;
  }

无法阻止用户使用Firebase身份验证进行身份验证。当他们进行身份验证时,他们所做的只是说“我是X Yz”并证明它

但是,您可以做的是防止他们访问您的数据库。例如,仅允许白名单用户读取您的数据库:

{
  "rules": {
    ".read": "root.child('allowedUsers').child(auth.uid).exists()"
  }
}
另见:

  • (你的白名单的倒排版本)

有道理。我将在Firebase的“身份验证”选项卡中列出一长串用户。正如我在问题中所说,这不会影响我正在使用的应用程序,因为他们的uid不会出现在
用户列表中。谢谢你的回答!