我正在嘗試在Firebase中創(chuàng)建用戶,并使用實(shí)時(shí)數(shù)據(jù)在數(shù)據(jù)庫中添加一些數(shù)據(jù)。我使用僅允許當(dāng)前用戶在其表中插入數(shù)據(jù)的規(guī)則來保護(hù)數(shù)據(jù)庫。即使我正在使用承諾,我也收到了一條消息,說“拒絕”。這是我的代碼:firebase.auth().createUserWithEmailAndPassword(email, password) .then( user => { const db = firebase.database(); const customer = db.ref().child('customers'); const key = firebase.auth().currentUser.uid; customer.child(key).set({ name : email, pwd : password, isRegistered : false, });如何在創(chuàng)建用戶后立即修改數(shù)據(jù)?謝謝大家編輯2:這些是規(guī)則{ "rules": { "customers": { "$uid": { ".read": "auth.uid === $uid", ".write": "auth.uid === $uid" } } }}
火基創(chuàng)造用戶承諾
躍然一笑
2022-09-29 16:52:48