I'm trying to build a Multi tenant SaaS application, and i know there are multiple approaches to that, but i picked the multi-database one i think it would fit most.
so I create a db for each tenant and store a table of tenants in the main db and connect users to their respective db based on the subdomain.
now my issue here is where to store the users, in the main db? or the tenant db, storing the users in the main db is going to make it difficult to get user related models in other db's, but storing it inside tenants db would make it difficult to authenticate on all users ...
also what's the best scenario?
- authenticate, get jwt token.
- send token with each request.
- on each request validate token, check subdomain, connect to respective tenant db, execute request.
is this a good approach? what should I do with the users table issue? ThnQ