Open tonypartridge opened 2 months ago
Issue is down to the tenant-menu.blade.php calling getUrl(). We need a new tenancy method 'getHomeUrl' or 'getTenantUrl' which returns the standard path generated for urls of the current tenant to avoid the excessive checks and the routing can be done on accessing the panel.
Package
filament/filament
Package Version
v3.2.91
Laravel Version
10.48.12
Livewire Version
3.5.0
PHP Version
8.3.8
Problem description
When enabling tenancy and the tenancy menu, the gate checks multiply by the amount of tenants + 1 additional tenant. In that the loaded tenants are being tested for what resources that tenant can access. To replicate, just add a policy against any resource and that policy is checked against every tenant in the tenant menu. In my instance, I've gone from 66 gate checks to 3306 gate checks by enabling the tenancy.
Expected behavior
The tenant gate checks should only be happening against the current active tenant, we have returned the results of tenants already which are limited to the current user and as such the resource checks should not be done of the tenants in the tenant menu.
Steps to reproduce
Add tenancy, add a Policy to a model, this will show X checks, add a tenant and you'll see the checks multiply, add another tenant and they increase again.
Reproduction repository (issue will be closed if this is not valid)
https://github.com/tonypartridge/filament-demo/tree/main
Relevant log output
No response
Donate 💰 to fund this issue