Firebase auth.uid在正则表达式中不起作用 [英] Firebase auth.uid not working in regex

查看:42
本文介绍了Firebase auth.uid在正则表达式中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只允许对uid在节点名称中某个位置的用户进行读取访问.

I want to allow read access to users only whose uid is somewhere in the node name.

我在Firebase中有以下规则:

I have the following rule in Firebase:

{
  "rules": {
    "messages" : {
      "$chat" :{
        ".read": "$chat.matches(/(auth.uid)/)"
      }
    }
  }
}

但是,这似乎不起作用.例如,当 $ chat user45-user99 auth.uid user45-user99 或仅仅是只是 user45 失败.

However, this does not seem to work. When $chat is user45-user99 for example and the auth.uid is user45-user99 or it is just simply user45 it fails.

我在做什么错了?

推荐答案

在我看来,您无法在Firebase RegEx中使用变量,因为它会将变量视为字符串.

It seems to me as you can't use variables in Firebase RegEx because it treats them as strings.

这就是我最终要做的事情:

Here is what I ended up doing:

$chats.contains(auth.uid)

这篇关于Firebase auth.uid在正则表达式中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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