I am interested in building a saas with angular. However, how do you allow users to have access to specific features based on which subscription they have paid for? e.g A user with a bronze package can send 10 emails and a user with a silver packager can send 50 emails.
Thank You
It depends on how secure you want to make it.
For maximum security, all actions need to happen on the backend, and there you can check the user's permissions. Usually, you create one or more permission groups on the backend, and then assign the user to one or more groups, depending on their subscription plan (different plans hold different quotas). You can send these permissions to the frontend, to hide some functionality/pages, but ultimately, you need to check for every action on the backend, if the user has permissions and quota hasn't been exceeded yet for the given time period (check user's quotas against subscription plan quotas and run a cron job that resets users quotas at the end of the month) .
You will need to look into some Role Based Authorization. Something like this may help https://jasonwatmore.com/post/2018/11/22/angular-7-role-based-authorization-tutorial-with-example
What will you using be using as your backend?
ahh I see thank you, I am considering firebase but I also want to learn node js so I haven't fully decided yet
You need to have this logic live on the back-end, anything that's front-end only is insecure. My way to do this would be to have some sort of middleware that sits in front of the routes that handles doing auth checks. Each time the protected route is hit the middleware gets triggered, and either allows the action or sends back some sort of error if the user has exceeded their privileges. How you set that up depends on your back-end and any frameworks you're using.
okk thank you very much
This can be sorted via conditional statements.
This comment was deleted 4 years ago