Home > Enterprise >  parent/child accounts in firebase
parent/child accounts in firebase

Time:01-30

I want to make an app where parents can buy a subscription for their children (one subscription per child) but I wonder how the corresponding accounts in Firebase would look like (buying the subscriptions themselves is out of scope of this question).

Are there best practises I should follow here?

  • I'll have a parent account in Firebase I guess
  • how can I create the children's accounts and how do I communicate their (generated?) credentials to them?

Thanks in advance for your insights!

CodePudding user response:

Firebase Authentication maintains a flat list of accounts per project. There is no built-in relations between any of the accounts, unless they are linked (which is not what you want here).

The best I can think of for the structure is to add a custom claim to the child accounts identifying their parent (and vice versa if needed). This needs to be done from a trusted environment (such as your development machine, a server you control, or Cloud Functions/Cloud Run). A local (Node.js, or other supported language) script or this extension that sets claims based on a Firestore document are probably the easiest way to get started with this.

If you choose to create the kid's accounts in a trusted environment with an Admin SDK too, you might as well add the custom claim there.

  •  Tags:  
  • Related