fireactjs / saas

A fully functional React web application for SaaS projects. It's built with React, Firebase and Stripe.
476 stars 177 forks source link

How do you determine if a user has a subscription? #13

Closed msacchetti closed 3 years ago

msacchetti commented 3 years ago

First - Amazing project. You saved me like 2 weeks of development with this boilerplate. Installed in 10 minutes and worked perfectly first try.

Is there a function in the boilerplate thats used to check if a user is subscribed so I can implement paywalled content? i.e. hasActiveSubscription()?

chaoming commented 3 years ago

Glad to hear that you like the project.

The subscription is not based on user level, but on account/project level, so that each user can have multiple subscriptions. If you create an account (not user) in the system, you can experience the workflow. To simulate a user level subscription, I suggest limiting 1 subscription per user, and try to read the user's subscription list (although it will only return 1 subscription). You can find the example code here: https://github.com/chaoming/fireact/blob/master/src/pages/auth/Home/index.js

msacchetti commented 3 years ago

Thank you for the direction. Based off that my solution will be to limit a user to only 1 account, and 1 subscription per account/user.

By changing the UI language from "Create Account" to something like "Create Your Billing Account", the workflow is:

[sign up/login, create billing account, subscribe].

So essentially each user has 1 billing account with 1 subscription.