Firestore规则auth似乎不起作用

时间:2018-04-23 14:54:01

标签: javascript firebase react-native google-cloud-firestore

我已经配置了如下的firestore规则:

service cloud.firestore {
  match /databases/{database}/documents {
    match /bills/{billid} {
      allow create: if request.auth.uid != null;
    }
  }
}

我添加如下记录:

import firebase from 'react-native-firebase';

const db = firebase.firestore().collection('bills');

const data = {
        year: year,
        month: month,
        description: description,
        dateCreated: new Date()    
};

db.add(data).then(ref => {
       console.log('added record with id: ', ref.id);
}).catch(error => {
       console.error("Error adding record: ", error);
}); 

但是,记录仍然进入firestore数据库,因为我已经设置了规则

允许创建:if request.auth.uid!= null;

我是否错误地设置了规则?

0 个答案:

没有答案