Spatie\permission and Spatie\Activitylog compatibility with Auth0

Hi,

I have been trying to integrate the latest version of Auth0 with spatie/laravel-permission ‘and Spatie\Activitylog’ in my Laravel 9 application; it was working fine with Laravel 8, but the latest Auth0 version changes drastically auth.php file, changing the guards used by Spatie plugins. I believe this is causing quite a few conflicts. I might be wrong with my diagnoses, probably the reasons could be different, but the following is the error which appears when trying to login into my application:

On “Spatie/permissions”:
Spatie\Permission\PermissionRegistrar::Spatie\Permission{closure}(): Argument #1 ($user) must be of type Illuminate\Contracts\Auth\Access\Authorizable, Auth0\Laravel\Model\Stateful\User given, called in /var/www/html/vendor/laravel/framework/src/Illuminate/Auth/Access/Gate.php on line 553

On “Spatie\Activitylog”:
Spatie\Activitylog\CauserResolver::getDefaultCauser(): Return value must be of type ?Illuminate\Database\Eloquent\Model, Auth0\Laravel\Model\Stateful\User returned

As you see above in each instance Spatie expects a type of Model or Function instead an Model\Stateful\User is returned by Auth0, so, triggering the error.

Could you please help me to understand how to solve the issue?
Thanks,
William

Hey there!

Yep sure but I guess it will be a better question for our Laravel gurus so if you can open a GitHub issue here:

it will be best as we will be able to talk with them directly. Once you have a link to it you can share it here so we can ping them. Thank you!

1 Like

HI Konrad,
thanks for the reply. Auth0 is an incredible tool, but also spatie/laravel-permissions, they are both widely used by developers, they were working fine together before latest update on Auth0 and on Laravel 8. Here is the ticket open with Laravel Auth0 and just pinging them now.
https://github.com/auth0/laravel-auth0/issues/350

Thanks

1 Like

Thank you! I’ll let them know in a few minutes!

Thanks Konrad,
could you please keep me posted? I really need this plugins conflict being sorted quite asap. We are building an application which relies heavily on those plugins. A question, I see that it’s in solved status, was it me clicking on solved by mistake? Thanks