PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Question By
Unsolved

Limit number of machines per user with API

alexpaiva

Dec 20th, 2022 10:02 AM

So, I have a .exe software. 2 questions: 1)I want the users to use it only with a login from the Wave SaaS website. To do this I assume simply to ask for a access token from the user (he gets this from his profile I assume?) and if API reply is "good login" then move forward.

2)When the user logs in, it checks if the user has reached the limit of X machines. (Machines being computers, servers, ...). 2.1)If it has not then it registers the current machine and increases the number of machines the user has tethered to his account. 2.2)If it has then the api returns an error message. Inside the Wave SaaS website is a reset button to reset this machines, thus setting the limit back to 0. This can only be requested every 24 hours for example.

How would I go forward to implement something like this? I don't believe it is too complicated but since I am no expert I wanted to hear some advice on this, especially regarding Wave's already built in features!

Thanks

bobbyiliev

Dec 21st, 2022 12:15 AM

Hi there Alex!

That is an interesting use-case for Wave! This should definitely work fine as you've described.

  1. The SaaS API token should work more or less out of the box with the existing API functionality. You can follow the steps on how to get the API token and use it here: Wave API docs. Let me know if you have any questions here!
  2. For this, what you could do is create a new Laravel Model called Machine with a User relationship. Then you could create a new Controller with an API Route that would handle the logic that you've described in 2.1 and 2.2.

Let me know if you have any questions!

alexpaiva

Dec 21st, 2022 02:43 PM

Thanks for your reply!

Regarding 1) and extending it: Imagine I offer 6 plans on wave. 3 for software A and 3 for software B. The login token would only login in software A if the user had either of the 3 plans for software A. Same goes for B. In this case is there a better implementation than this following logic: -User logs in .exe file -Request is made to API, with access token provided by the user in the .exe file and a special code identifying if it's software A or software B. -The API (Wave side) first checks if the access token is valid. If it is then it takes the special code to understand if the request is comming from software A or B then if for example the requests comes from software A it checks if the given user is on a plan that is tethered to software A, and only then it replies with "good login".

For 2 I will have to research what you mentioned, any 'good' examples you can link me if you can?

Thanks.