阻止用户的Firebase规则

时间:2017-05-05 11:04:35

标签: javascript angular firebase ionic-framework angularfire2

我在firebase中有以下数据结构,无论如何都要使用firebase规则停止读取用户UID在块节点/列表中。 enter image description here

1 个答案:

答案 0 :(得分:-1)

@jay感谢您的回复,这是我的firebase结构和firebase规则。

{
  "rules": {
    ".write": "auth != null",
      ".read": "auth != null",
    		"accounts": {
        ".read": true,
      	".indexOn": ["username"]
    	},
    		"requests": {
      	".read": true,
      	".write": "auth != null"
    	}
  }
}

{
  "accounts" : {
    "2aVaHeIsTpbZYq7eXHG2nM3lUu53" : {
      "dateCreated" : "Fri Apr 14 2017 12:23:21 GMT+0100 (BST)",
      "description" : "Hello! I am a new FireLine user.",
      "email" : "test@gmail.com",
      "img" : "https://",
      "name" : "Firebase User",
      "provider" : "Firebase",
      "userId" : "2aVaHeIsTpbZYq7eXHG2nM3lUu53",
      "username" : "FirebaseUser2aVaHeIs"
    },
    "OCXMwQVzr4NMXIJNj73fOankChr1" : {
      "conversations" : {
        "VhPhN8e2NRYdrzMqUv9x5a2WzrJ2" : {
          "conversationId" : "-KdvS_lEyIyW52ekSZPD",
          "messagesRead" : 6
        }
      },
      "dateCreated" : "Fri Feb 24 2017 14:23:48 GMT+0000 (GMT Standard Time)",
      "description" : "Þþttttttkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk",
      "email" : "test@gmail.com",
      "friends" : [ "VhPhN8e2NRYdrzMqUv9x5a2WzrJ2" ],
      "groups" : {
        "-KdvemO-UxsMkhiaWogL" : {
          "messagesRead" : 7
        }
  },
  "blocks" : {
    "VhPhN8e2NRYdrzMqUv9x5a2WzrJ2" : {
      "OCXMwQVzr4NMXIJNj73fOankChr1" : true
    }
  },
  "conversations" : {
    "-KdvS_lEyIyW52ekSZPD" : {
      "dateCreated" : "Sun Feb 26 2017 17:27:18 GMT+0000 (GMT)",
      "messages" : [ {
        "avatar" : "https://",
        "date" : "Sun Feb 26 2017 17:27:18 GMT+0000 (GMT)",
        "message" : "hhh",
        "sender" : "OCXMwQVzr4NMXIJNj73fOankChr1",
        "type" : "text"
      }, {
        "avatar" : "https://",
        "date" : "Sun Feb 26 2017 18:09:45 GMT+0000 (GMT Standard Time)",
        "message" : "hhhhh",
        "sender" : "OCXMwQVzr4NMXIJNj73fOankChr1",
        "type" : "text"
      }
  },
  "groups" : {
    "-KdvemO-UxsMkhiaWogL" : {
      "dateCreated" : "Sun Feb 26 2017 18:24:58 GMT+0000 (GMT)",
      "description" : "lllllllllllllllllllllllllllllllllllllllllll",
      "img" : "https://",
      "members" : [ "OCXMwQVzr4NMXIJNj73fOankChr1", "VhPhN8e2NRYdrzMqUv9x5a2WzrJ2", "sdfsdfsdf" ],
      "messages" : [ {
        "avatar" : "https://",
        "date" : "Sun Feb 26 2017 18:24:58 GMT+0000 (GMT)",
        "icon" : "md-chatbubbles",
        "message" : "This group has been created.",
        "sender" : "OCXMwQVzr4NMXIJNj73fOankChr1",
        "type" : "system"
      }, {
        "avatar" : "assets/images/profile.png",
        "date" : "Tue Apr 11 2017 22:34:59 GMT+0100 (GMT Daylight Time)",
        "icon" : "md-create",
        "message" : "Firebase User has changed the group name to: yest.",
        "sender" : "VhPhN8e2NRYdrzMqUv9x5a2WzrJ2",
        "type" : "system"
      }
  },
  "likes" : {
    "OCXMwQVzr4NMXIJNj73fOankChr1" : {
      "-Kh3tVr2tdf2tsDoFj2e" : {
        "liked" : true
      },
      "-Kh3tWl6EDHM8SN-oKXv" : {
        "liked" : true
    },
    "VhPhN8e2NRYdrzMqUv9x5a2WzrJ2" : {
      "-Kh3tXaDvavmQCZ3gIyN" : {
        "liked" : true
      },
      "-Kh3tYEsRK0dDHlkNaKD" : {
        "liked" : true
    }
  },
  "wallposts" : {
    "-Kh3tVr2tdf2tsDoFj2e" : {
      "date" : "Thu Apr 06 2017 21:12:58 GMT+0100 (GMT Daylight Time)",
      "message" : "fgdfgdgdfgdfg",
      "sender" : "OCXMwQVzr4NMXIJNj73fOankChr1",
      "type" : "text"
    },
    "-Kh3tWl6EDHM8SN-oKXv" : {
      "date" : "Thu Apr 06 2017 21:13:02 GMT+0100 (GMT Daylight Time)",
      "message" : "dfgdfgdfgdfgdfg",
      "sender" : "OCXMwQVzr4NMXIJNj73fOankChr1",
      "type" : "text"
   }
  }
}