Closed jackadair closed 1 year ago
I can't reproduce this. I need some more help to figure out what might be the problem.
The "Unauthorized" validation error triggers when selected parent is some tenant that user has no access to. Access to the tenant depends on what tenant the current user belongs to. The tenant user belongs in and all tenants under that are authorized for that user.
Normally the parent field won't list tenants that user don't have access to, because tenants collection limits read access to only documents that are authorized for the user. So it's weird that this happens at all.
@joas8211 Thanks for taking a look, I just dropped by database to try again and can reproduce under the following conditions:
plugins: [
tenancy()
]
[20:22:32] WARN (payload): rollbackTransaction called when no transaction exists
[20:22:32] ERROR (payload): NotFound: The requested resource was not found.
at findByID (/home/node/app/node_modules/payload/src/collections/operations/findByID.ts:109:15)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at findByIDHandler (/home/node/app/node_modules/payload/src/collections/requestHandlers/findByID.ts:19:17)
plugins: [
tenancy({
isolationStrategy: "path"
)
]
localhost:3000/tenant-slug/admin
. Maybe there's just some setup that I've missed...I will also try to do the programmatic setup as written in the docs see if that changes anything.
I tried to replicate with the latest blank template + Lexical running in Docker using docker-compose.yml provided in the template, and still no luck. You have some other dependencies listed so I assume you have some project you are working on instead of trying this out in isolation. So, is it possible that your code is using transactions but not resolving them? The following warning you provided is indicating something like that.
[20:22:32] WARN (payload): rollbackTransaction called when no transaction exists
@joas8211 Finally found my issue, it was due to my code but i'll leave this here if anyone else comes across it:
auth: {
depth: 0,
},
instead of:
auth: true
Had it left over from Payloads docs about creating multi-tenancy before I found your plugin.
Thanks again for taking a look!
I have succeeded in creating my user and root tenant however, when trying to create further tenants I am receiving a unauthorized error on the
parent
field:Dependencies:
It is also a required field so I can't create any additional tenants.
Any help appreciated!
Screencap
https://github.com/joas8211/payload-tenancy/assets/54963231/1e7cca42-6007-4421-adbd-8629f0ecda0e