3

Lets assume we have a data structure similar to the one below, and using fan-out update we want to convert an invitation to a user.

  • root
    • users
      • KC88nKzEqsx6AlPjrvp
        • email : test1@yahoo.com
        • uid: 19570b6c-afd0-xxxx-xxxx-650be04c5767
      • KCAW6T_au2ROnJcaf85
        • email : test2@yahoo.com
        • uid: 22570b6c-afd0-xxxx-xxxx-650be04c5767
    • invitations
      • KCZndfnKzEqrtr6AlPjrvp
        • email : test3@yahoo.com
      • BYYAW6T_au2Rffeaf85
        • email : test4@yahoo.com

Update code:

var update = {}
update[‘invitations/KCZndfnKzEqrtr6AlPjrvp’] = null
update[‘users/DDd83sx6AlPjrvp’] = {email:test3@yahoo.com, uid: 773492-afd0-344-4535-650be04c5767}

ref.update(update);

How can i write validate rules in Bolt, that will check if:

  1. Invitation for such email existed.
  2. The newly created user email is equal to email on invitation
  3. User uid is his actual id from auth object.
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Did you try anything yet? Some of these should not be too difficult if you follow along with the Bolt documentation and read recent questions about [firebase-bolt] and [firebase-security]. – Frank van Puffelen Mar 06 '16 at 23:13
  • @frank thank's for your interest. I'm aware of documentation in [link](https://github.com/firebase/bolt/blob/master/docs/language.md) and on firebase website. Yet i have a problem writing validation rules that mention 3 nodes that are not siblings, and path leading to them is dynamic (i.e KC88nKzEqsx6AlPjrvp array key). – Łukasz Patecki Mar 07 '16 at 18:35
  • Ensuring unique properties will typically require that you add a dedicated node for the purpose. See http://stackoverflow.com/questions/25294478/how-do-you-prevent-duplicate-user-properties-in-firebase – Frank van Puffelen Mar 07 '16 at 19:56

0 Answers0