joas8211 / payload-tenancy

Multi-tenancy plugin for Payload CMS
MIT License
122 stars 6 forks source link

Let user switch tenant, multiple tenants per user? #22

Open timboozle opened 9 months ago

timboozle commented 9 months ago

I would like to use this plugin as a multisite (blogging) solution. Our company manages 3 websites and I would like users to be able to switch environments (maybe through their profile), so they will only see the content for the website they are working on.

What I'm confused about is that the second tenant needs to have a parent tenant. Isn't it possible to have tenants act as websites that have nothing to do with each other?

Also, when my user is connected to the root tenant and then switch to a child tenant, it works, but I can never switch back to any other tenant.

Some advice would be appreciated!

Thanks

hades200082 commented 7 months ago

What I'm confused about is that the second tenant needs to have a parent tenant. Isn't it possible to have tenants act as websites that have nothing to do with each other?

Create a single root tenant that has ultimate control of all users & tenants, then create each of the 3 sites as sub-tenants under that.

This way you can have users in the root tenant that can login to any of the sites, but also some users who are site-specific.

Just think of the root tenant as being there for access control. It might even be possible to hide all the resource collections, etc. from the root tenant as they don't need them - I asked this question in #34

Also, when my user is connected to the root tenant and then switch to a child tenant, it works, but I can never switch back to any other tenant.

If you are using "User" isolationStrategy then this will be the issue. Try using "path" isolationStrategy instead once you have it all set up.