Closed acobrerosf closed 7 months ago
Never mind, after some deeper research I found out that I had to register the policy in the AuthServiceProvider and link it to the AuthenticationLog model.
This is the first time I need to add permissions to a third party plugin on Filament so I had no idea this could happen.
Thanks for your work!
@acobrerosf Nice, many thanks for your feedback! :)
Never mind, after some deeper research I found out that I had to register the policy in the AuthServiceProvider and link it to the AuthenticationLog model.
Can't make it work, can you show how you did it please?
Never mind, after some deeper research I found out that I had to register the policy in the AuthServiceProvider and link it to the AuthenticationLog model.
Can't make it work, can you show how you did it please?
Sure! I just modified the AuthServiceProvider as shown below:
<?php
namespace App\Providers;
// use Illuminate\Support\Facades\Gate;
use App\Policies\AuthenticationLogPolicy;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Rappasoft\LaravelAuthenticationLog\Models\AuthenticationLog;
class AuthServiceProvider extends ServiceProvider
{
/**
* The model to policy mappings for the application.
*
* @var array<class-string, class-string>
*/
protected $policies = [
AuthenticationLog::class => AuthenticationLogPolicy::class,
];
/**
* Register any authentication / authorization services.
*/
public function boot(): void
{
//
}
}
Make sure to run as well:
php artisan shield:install
To force the plugin to generate the policies and permissions needed for this new resource.
I have installed your package and works great, however I can't find a way to hide the section or block users that has a role with no permissions to handle that resource.
I don't have to do anything special for the sections that I build myself, I create a new resource and with the Shield plugin I can assign to a role the permissions to be able to create, view, edit, etc. that resource. Just by doing that the left menu item shows or not depending on the role, however with your plugin it seems to ignore these rules.
Is there anything else I need to do?