archtechx / tenancy

Automatic multi-tenancy for Laravel. No code changes needed.
https://tenancyforlaravel.com
MIT License
3.62k stars 426 forks source link

Compatibilty issues with spatie/laravel-activitylog #1182

Closed skills-up closed 9 months ago

skills-up commented 9 months ago

Bug description

After enabling spatie/laravel-activitylog into various tenant models, tenancy has stopped working.

Subdomain now redirect to the central domain, and attempt to programmatically authenticating users results in redirect to login page.

Steps to reproduce

  1. Create a working multi-tenant application
  2. Add spatie/laravel-activitylog package via composer
  3. Add LogsActivity trait and getActivitylogOptions method to various models in App\Models\Tenant namespace
  4. Create a new tenant
  5. Seed the database for new tenant
  6. Programmatically add and authenticate tenant user to tenant database
  7. Visit the tenant domain

At step#5 tenancy database will be seeded using database/seeders/DatabaseSeeder instead of database/seeders/tenant/DatabaseSeeder At step#6 you'll be redirected to login page in browser At step#7 you'll get redirected to central domain instead

Expected behavior

While the database is getting created alright, the domain app, as well as authentication and authorization functionality appears to have been broken. This may have to do with spatie/laravel-activitylog using auth()->user() to populate caused by.

Laravel version

10.10

stancl/tenancy version

3.7

stancl commented 9 months ago

For support with integrations, you can ask on our Discord. This is not a bug in tenancy.