我尝试向我的 firestore 数据库添加一个简单的规则。但是当我这样做时,当前用户的数据就会消失。
如果我控制台记录当前用户,它会打印出当前用户 UID 和电子邮件等。我可以注销并登录。但没有数据显示。有没有人知道我需要做什么或应该从哪里开始,因为现在我感到迷茫,我不知道我应该开始看什么。顺便说一句,我使用 React native 和 Redux 来获取我的数据。
这是我尝试添加的规则
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
这就是我在 redux 操作中获取用户的方式:
//fetch UserInfo from firebase
export function fetchUser() {
return dispatch => {
firebase
.firestore()
.collection('users')
.doc(auth().currentUser.uid)
.get()
.then(snapshot => {
if (snapshot.exists) {
dispatch({type: USER_STATE_CHANGE, currentUser: snapshot.data()});
} else {
console.log('does not exist');
}
});
};
}