Realtime database setup for both User Accounts and Registration Screen

SAB 9.0.0
There are different rules in the documentation for User Accounts and Registration Screen.

  • Do we need to combine them if we are using both?
  • How?

User Accounts:

{
  "rules": {
    "authenticated-users": {
      "$uid": {
        ".read": "$uid === auth.uid",
        ".write": "$uid === auth.uid"
      }
    }
  }
}

Registration Screen:

{
  "rules": {
    "users": {
      "$uid": {
        ".read": false,
        ".write": "$uid === auth.uid"
      }
    }
  }
}

or

{
  "rules": {
    "users": {
      "$uid": {
        ".read": "(auth != null) && (auth.token.email =='me@abcd.com')",
        ".write": "$uid === auth.uid"
      }
    }
  }
}

If you are using both, you will need to combine them as follows:

{
  "rules": {
    "users": {
      "$uid": {
        ".read": false,
        ".write": "$uid === auth.uid"
      }
    },
    "authenticated-users": {
      "$uid": {
        ".read": "$uid == auth.uid",
        ".write": "$uid == auth.uid"
      }
    }
  }
}
1 Like

Thank you.
Maybe this is something to add to the documentation?

I like Greg’s suggestion. It should also be noted that if you have multiple apps in one Firebase container, as we do, it appears these edits only need to be done once per container. If you have made the edits to the Firebase container for one app, it will apply to all apps in that container. From that point all that is needed is to check the box/s in SAB/RAB to enable the User account/s.

@Dan_Neville

Would you mind fleshing out “multiple apps in one Firebase container” for me.
I am already at my limit of number of apps allowed in one Firebase account.

When tracking more than one app in a “Firebase Container” (the limit is usually 30 apps per container), if you want to enable the “User account” for more than one of the apps that happen to be in that container, and you follow the instructions/directions from SAB (page 77, section 21.2) that describe setting up rules for User account authentication in the Firebase container, it is not clear that these rules set all the User accounts permissions for all the apps in that container. Therefore, this step only needs to be done once for each container.

With that done, any app using that container only needs to have the two boxes checked in SAB for the user account/s to be enabled. The one on the:

  • Firebase tab > Firebase Realtime Database (for saving user details)

and

  • User Accounts > Enable user accounts.

This is not clear in the directions on pages 77ff. If one tries to go back to the Firebase container to set up a second app “User accounts” for different app, one that is already in that Firebase container, the directions for the Firebase steps don’t make sense, because you have already done them.

Hope that helps.

I still don’t understand what you mean by a Firebase “container”.
My Firebase knowledge is quite limited.

We have 10 projects on one Firebase account - another app (not SAB), and 9 SAB apps (one for each language).

We have 4 other languages to add to the list, but I would prefer to allocate them to the same account if possible.

Are you talking about adding apps here:
image

How does this affect the analytics? Are they all lumped together or do you get stats for each app?

Also, would this mean 1 user account for all the apps?

Yes, when Dan says “multiple apps in one Firebase container”, he is referring to adding multiple apps in a single Firebase project.

If you do this:

  • You will be able to view the analytics of all apps together, or choose just one or some of them to view analytics.
  • Synchronised account data (highlights, bookmarks, etc.) will be saved to one Firebase Realtime database (separated by app, not confused with each other).
  • If a user signs up for an account in an app, they will need to use the same user account to access other apps in the same project.
  • If multiple apps in the same Firebase project have registration screens, the registered users will currently be added to the same database table (this is a limitation that we have noted and will fix in a future version).
1 Like

@richard
I see the registration data gets lumped together with no way of telling the apps apart.
Will it be possible to add a hidden field to the user registration to identify the source app?

As a work around, I have used the fieldname to indicate which app the data is coming from.