"权限被拒绝"安全规则导致的Firebase错误

时间:2016-02-01 18:35:36

标签: android firebase firebase-security

我在Permission denied

上致电setValue()后收到firebaseRef错误

我的规则看起来像这样:

{
    "rules": {
      ".read" : "auth.provider == 'google'",
      ".write" : "auth.provider == 'google'",
      "hashTags": {
        "$userEncodedEmail": {
          "$hashTag": {
            ".validate": "newData.hasChildren(['createByUserEmail', 'name','timeStampLastUsed','tasksKeys'])",                
            "createByUserEmail": {
              ".validate": "newData.isString() && newData.val().matches(/^[A-Z0-9,_%+-]+@[A-Z0-9,-]+,[A-Z]{2,4}$/i)" 
            },
            "name": {
              ".validate": "newData.isString() && newData.val().length <= 500"
            },
            "timeStampLastUsed": {
              ".validate": "newData.hasChildren(['timestamp'])",
              "timestamp": {
                ".validate": "newData.isNumber()"
              },
              "$other": {
                ".validate": "false"
              }
            },
            "tasksKeys": {
            },
            "$other": {
                ".validate": "false"
            }
          }
        }
      }
}

Java模型是:

public class HashTagModel {

    private HashMap<String, Object> timeStampLastUsed;
    @Expose
    private String name;
    @Expose
    private String createByUserEmail;
    private List<String> tasksKeys;
    ...
}

我也尝试过:

{
    "rules": {
      ".read" : "auth.provider == 'google'",
      ".write" : "auth.provider == 'google'",
      "hashTags": {
        "$userEncodedEmail": {
          "$hashTag": {
            ...
            "tasksKeys": {
               "$taskId": {
                   ".validate": "newData.isString()"
               }
            },
            ...
          }
        }
      }
}

0 个答案:

没有答案