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

查看:120
本文介绍了我怎么知道什么安全的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天全站免登陆