本文介绍了FireStore安全规则quest.auth.uid不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
FiRestore安全规则不起作用。帮帮我。无法读取用户/用户ID的文档数据。-安全规则-
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId=**} {
// Missing or insufficient permissions.
allow read, write: if request.auth.uid == userId
// this is work.
//allow read, write: if request.auth != null
}
})
--------------main.js--------------------
import Vue from 'vue'
import Quasar from 'quasar'
import firebase from 'firebase'
import 'firebase/firestore'
Vue.config.productionTip = false
Vue.use(Quasar)
let app;
firebase.initializeApp({
apiKey: "",
authDomain: "",
databaseURL: "",
projectId: "",
storageBucket: "",
messagingSenderId: ""
})
firebase.auth().onAuthStateChanged(user=> {
if (user) {
let ref = firebase.firestore().collection('users').doc(user.uid)
ref.get().then(snapshot=>{
// Error !! : Missing or insufficient permissions.
}
}
if(!app){
Quasar.start(() => {
app = new Vue({
el: '#q-app',
render: h => h(require('./App').default)
})
})
}
})
FireBase^4.8.0VUE^2.5.0显然,Require.auth.uid似乎不能正常工作。我哪里错了?
推荐答案
我自己解决了
match /users/{user} {
allow read, write: if request.auth.uid == user
match / {docs = **} {
allow read, write: if request.auth.uid == user
}
}
这篇关于FireStore安全规则quest.auth.uid不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!