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()"
}
}
另见:
- (你的白名单的倒排版本)
用户列表中。谢谢你的回答!