简体   繁体   中英

Best invitation system with roles with Firebase

I'm wondering what would be the best way of building an invitation system with roles with Firebase.

Taken this:

  • userA invites userB's email address to join his account, with role "READ_ONLY".
  • userB registers with his email address, accepts the pending invitation, and has access to userA's account with role "READ_ONLY"

The main question here is where should I store the invitations data?

  1. As a dedicated collection "/invitations"?
  2. As a sub-collection "account/{id}/invitations"?
  3. Create a user with a dump password and keep the role in the user claims?
  4. Something else ♂️?

I'm afraid solutions 1 & 2 would cost too many reads each time a user registers. Solution 3 would not be the best UX as user would have to reset his password after trying to register (because email address would already be in use)

Any thoughts?

Thanks

You can create a collection of invitations where you can store all invitations with:

  1. user who invited
  2. user who was invited
  3. role
  4. expiration

Send an email to the person who is invited invitation ID. In case the email has an account and is login, he just needs to accept or reject it, otherwise, ask him for registration or login.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM