Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugin-multi-tenant): fixed hardcoded user tenants field #10782

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

robclancy
Copy link
Contributor

What?

When using custom slugs and field names the tenancy field added to the users would still attempt to use tenants and fail.

Why?

The tenant/tenancy are hardcoded in tenantsArrayField()

How?

Added the same args that are used in tenantsField() for the field names and relation.

Copy link
Contributor

@JarrodMFlesch JarrodMFlesch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the intent is correct with passing in field names for the tenants array. However, the field names should be specific - you should not be required to use the same name as the tenants collection or the tenant field name.

You will also need to search for places where we are doing tenants.tenant where queries and thread these two new name properties to those locations.

Let me know if you need any help with this!

@robclancy robclancy force-pushed the main branch 2 times, most recently from faf8186 to 3642f63 Compare January 28, 2025 09:23
@robclancy
Copy link
Contributor Author

I haven't directly tested anything yet, I will be trying out this on our cms soon.

Copy link
Contributor

@JarrodMFlesch JarrodMFlesch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small change for the types, but overall looks good. Thank you!

packages/plugin-multi-tenant/src/types.ts Outdated Show resolved Hide resolved
### What?
When using custom slugs and field names the tenancy field added to the
users would still attempt to use tenants and fail.

### Why?
The tenant/tenancy are hardcoded in `tenantsArrayField()`

### How?
Added the same args that are used in `tenantsField()` for the field
names and relation.
@JarrodMFlesch JarrodMFlesch merged commit 9638dbe into payloadcms:main Jan 29, 2025
67 checks passed
Copy link
Contributor

github-actions bot commented Feb 5, 2025

🚀 This is included in version v3.21.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants