- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
例如,我有以下规则:
match /users/{userId} {
allow create: if isCurrentUser(userId)
&& request.auth.token.firebase.sign_in_provider != 'anonymous';
allow update: if isCurrentUser(userId);
}
function isCurrentUser(userId){
return request.auth.uid == userId;
}
我正在尝试为其添加单元测试并以这种方式初始化应用程序:
const firebase = require("@firebase/testing");
const app = firebase
.initializeTestApp({
projectId: "some-firestore-emulator",
auth: {
uid: "bohdan",
// case 1
token: {
firebase: {
sign_in_provider: "google.com"
}
},
// case 2
providerData: {
providerId: "google.com"
},
//case 3
providerId: "google.com"
}
})
但是当我尝试创建文档时失败:
app.firestore().collections("users").doc("bohdan").set({ name: "Bohdan" })
我有这个错误:
FirebaseError: 7 PERMISSION_DENIED:
Property firebase is undefined on object. for 'create' @ L15
如何运行initializeTestApp
并成功创建文档?
最佳答案
app.firestore().collections("users").set({ name: "Bohdan"})
是错误的。
您应该指定与 request.auth.uid
值相同的文档 ID。像这样。
app.firestore().collection("users").doc("bohdan").set({ name: "Bohdan"})
您可以查看文档和我的 firebase 测试示例吗?
参见:
我试过了。将 initializeTestApp()
arg 从 auth.token.firebase.sign_in_provider
更改为 auth.firebase.sign_in_provider
。
const app = firebase
.initializeTestApp({
projectId: "some-firestore-emulator",
auth: {
uid: "bohdan",
// // case 1
// token: {
// firebase: {
// sign_in_provider: "google.com"
// }
//},
firebase: {
sign_in_provider: "google.com"
}
}
})
您能检查以下链接吗?
关于javascript - @firebase/testing - 如何使用 auth.providerId 调用 `initializeTestApp`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60217886/
我正在经历这个令人沮丧的问题。令人恼火的是,他们为 Firebase 进行了这样的更新,几乎没有特定文档。我收到同样的错误:“AuthDataResult”类型的值没有成员“providerID”。这
我在使用最新版本的 FirebaseAuth 5.0 时遇到问题,这是我的代码: if let email = emailField.text, let password = passwordFiel
文档说 For example, 'facebook.com', or 'google.com'. 但是,是否可以在某处找到详尽的 list ,我可以依赖它吗?这些 id 可以是变体吗,比如“face
我对最新版本的 FirebaseAuth 5.0 有疑问这是我的代码: func registerUser (withEmail email: String, andPassword password
例如,我有以下规则: match /users/{userId} { allow create: if isCurrentUser(userId) && request.auth.t
我有一个使用 Firebase 进行身份验证的应用程序。 我允许用户使用 Google/Facebook/Twitter 或使用电子邮件和密码登录。 此外,我已在 Firebase 中激活用户只能为每
我是一名优秀的程序员,十分优秀!