How to implement collaborator invitations using firebase?

I am developing an application with firebase and angular and corner fire. I would like to invite the collaborators function in many ways similar to how firebase itself implements collaboration, that is, the application user can enter an email address to invite collaborators who would send an email and create an inviteToken, as is done at the invitation collaborators in the firehouse itself. I understand that security rules (to limit collaborator access) and schemes (folder / collaborators)?) Are one of the aspects that can be implemented using the built-in firebase and angular. My question is how best to implement the email invitation and inviteToken? What would be the most appropriate way to implement such an invitation feature? Could this be done using native firebase? Or will you need to implement a separate, server-side code (nodejs?)? Perhaps someone from the firebase team may be based on how Firebase itself implements collaboration.

+6
source share
1 answer

You can collaborate by hashing the email address of the user with whom you want to share a specific piece of data and store it in the permission field.

For example, start with the path / items / item 1, which belongs to "user1":

{ "items": { "item1": { "data": "foobar", "permissions": { "user1": true } } } } 

You have set up security rules for data as follows:

 { "rules": { "items": { "$item": { ".read": "data.child('permissions').hasChild(auth.uid)", ".write": "data.child('permissions').hasChild(auth.uid)" } } } } 

Now that "user1" wants to share "item1" with "user2", they just write the value "user2" and set it to true under the permission key. You can expand the structure of the Permissions key to the extent you want (for example: co-authors can only read, but the owner can read and write, etc.).

In practice, you can, for example, use user address hashes. Also check out Simple Login for an easy way to authenticate your users (after authentication, the auth variable used in the above security rules is automatically set for you).

+2
source

All Articles