I am working on a multi-tenant domain based saas project and want to be able to have cross-tenant users
I am using the pattern “tenant-discriminator-in-shared-tables”, i.e. I have a tenant ID for all resources, however users to tenants is many to many
I am looking for guidance on good approaches
Should I have a join table such as user_tenant and manage that when an existing user registers and uses a new tenant?
Any suggestions about modifying exist logins based on phx.auth.gen?
thanks
Have you checked out the Ecto “how-to” guides on multi-tenancy?
https://hexdocs.pm/ecto/multi-tenancy-with-query-prefixes.html
https://hexdocs.pm/ecto/multi-tenancy-with-foreign-keys.html
thanks @arcanemachine I have now, I actually have the tenant pattern in place except for users
I am stuck on the best approach to making cross tenant users
if user1 is member of tenant1
then user1 joins tenant2
should I use a many to many user_tenants join table?
how to modify the phx.gen.auth generated controllers to manage this?