我怎么知道什么安全 Firebase 规则给了我一个错误? [英] how can i know what security firebase rule give me a error?

查看:25
本文介绍了我怎么知道什么安全 Firebase 规则给了我一个错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个 firebase 安全规则:

".validate": "newData.val().length <2"

当新的 data.length 大于 2 时,Firebase 会返回一个错误消息PERMISSON_DENIED".

我想知道是否有办法获得新数据太长"这样的错误信息.

谢谢

解决方案

Firebase 安全规则返回相同的错误,无论哪个部分失败.您无法控制错误消息.如果您正在排查操作失败的原因,您可以使用 Firebase 仪表板中的模拟器.但这似乎不是您要找的.

向用户显示更智能的错误消息是一个好主意.但我建议通过在将数据发送到 Firebase 之前验证数据来实现这一点.所以执行客户端验证,只有在通过验证时才将数据发送到 Firebase.

更好的是:不允许用户输入超过 2 个字符.

I have this firebase security rule:

".validate": "newData.val().length < 2"

When the new data.length is > 2, Firebase returns a error that says "PERMISSON_DENIED".

I would like to know if there is a way to get a error info like this "the new data is to long".

Thanks

解决方案

Firebase security rules return the same error, no matter what part failed. You have no control over the error message. If you're troubleshooting why an operation is failing, you can use the Simulator in your Firebase dashboard. But that doesn't seem what you're looking for.

Showing a more intelligent error message to the user is a great idea though. But I'd recommend doing that by validating the data before you send it to Firebase. So perform client-side validation and only send the data to Firebase if it passes the validation.

Better yet: don't allow the user to enter more than 2 characters.

这篇关于我怎么知道什么安全 Firebase 规则给了我一个错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆