def sign_up(email, password):
# create user node with UID under NGO
user = auth.create_user_with_email_and_password(email, password)
uid = user['localId']
db.child("NGO").child(uid).set({
'email': email
})
return user
if __name__ == "__main__":
config = {
# API config
}
firebase = pyrebase.initialize_app(config)
db = firebase.database()
auth = firebase.auth()
user = sign_up(email, password)
Now to make this code work, the only solution I have come up with so far is
{
"rules": {
"NGO": {
".read": false,
".write": true,
"$uid": {
".read": "auth.uid === $uid",
".write": "auth.uid === $uid"
}
}
}
}
This approach unfortunately gives write access to the entire NGO node to any $uid
What did not work (it can't create a new node named $uid itself but can read/write if it already exists) -
{
"rules": {
"NGO": {
"$uid": {
".read": "auth.uid === $uid",
".write": "auth.uid === $uid"
}
}
}
}
The RTDB structure looks like this
