Multi-tenant: allow users to exists per tenant (non-global users) #14304
Replies: 1 comment 2 replies
-
|
Hi! I actually faced the same problem when building a multi-tenant setup with Payload v3. For example, for tenant This way, the default auth strategy continues to work without modification, and I just need to provide the tenant ID when signing up or logging in. It’s definitely a bit of a hack, and I’d also prefer a cleaner solution with a proper multi-tenant auth strategy and unique constraints per tenant, similar to what you’re describing, but this approach works reliably for now. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
i'm working with Payload v3 in order to build a multi-tenant application, and one of my requirements is to have user defined per-tenant, rather than app-wide.
In other words i'd like to:
I've already tried removing the unique constraint from the email field in the Users collections and adding a unique index on the (email, tenant) tuple, but that alone doesn't work.
After digging through the docs and the code i found that simply changing the collection definition is not enough since the local-strategy enforce uniqueness at code level.
Has anyone implemented something similar?
Someone has any ideas about creating a "multi-tenant local-strategy" for authentication?
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions