rwaddin / firebase-chat

just for learning, how to use firebase authentication to secure realtime database with seeting in rule

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

firebase-chat

Just for learning, how to use firebase authentication to secure realtime database with setting rule

rule firebase

{
  "rules": {
    "threads":{
      "$user_id" : {
        ".write" :"auth != null && auth.uid == $user_id && !data.exists()",
        ".read" : "auth != null && auth.uid == $user_id "
      },
      ".read" : "root.child('agents').hasChild(auth.uid)"
    },
    "messages": {
      "$user_id" : {
        ".write" : "auth != null && auth.uid == $user_id || root.child('agents').hasChild(auth.uid)",
        ".read" : "auth != null && auth.uid == $user_id"
      },
      ".read" : "root.child('agents').hasChild(auth.uid)"
    },
    "agents": {
      "$user_id": {
        ".write": "auth != null && auth.uid == $user_id && !data.exists()",
        ".read": "auth != null && auth.uid == $user_id"
      }
    }
  }
}

firebase realtime structure

This is just for learning only. You can modify this script like all you want.

{
  "threads": {
    "<uid>": {
      "referrer" : "",
      "started": "",
      "threadid": ""
    }  
  },
  "messages": {
    "uid": {
      "firebaseid": {
        "aktor": "",
        "message": "",
        "status": "",
        "time" : ""
      }
    }
  },
	"agents": {
		"uid": {
			"dept": "",
			"mail": "",
			"ref": "",
			"uid": " "
		}
	}
}

About

just for learning, how to use firebase authentication to secure realtime database with seeting in rule


Languages

Language:HTML 97.7%Language:JavaScript 2.3%