meteorsubscriptionaccountsinvite

Allow users to invite team members to Meteor application & link team accounts


I've created a system where a user can sign up for my application, start a paying subscription & then has access to my app.

I need to create another system that allows the user to invite their team members but in such a way that if the original account's subscription ends, I can also deny the invited users access to the app.

I'm not sure how to do this.

Effectively, the interaction flow would be as follows:

User signs up -> Pays for app -> Enters dashboard -> Inputs team member email -> team member receives email -> team member follows link -> creates password -> enters dashboard in new user account that's linked to original

So if the original subscription ends I can also deny the user access to the app.

I hope this makes sense & appreciate any tips on how to do this.


Solution

  • A common pattern for this is to include a invitedBy key in the users collection. When the first member invites other team members, set the invitedBy key in the invited members to the _id of the inviting member. In your code that expires the subscription of the first member, do:

    Meteor.users.find({ invitedBy: userId })
    

    and then take the appropriate actions to cancel/suspend their subscriptions or ask them to pay up.

    The key is to include a reference to the inviting user in the signup link that is sent to the invitees. In my app I manage this with a separate Invitations collection that contains the inviting user's _id along with a token that is used in the url.