You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I'm trying to create new roles and add permissions to them. i want to make some modules only accessible by some of the new roles I've created. I followed the twill documentation and I still get Forbidden yellow screen error when i try to access a certain module as the new user role i created.
It looks like the code in AuthServiceProvider is not redefining twill's default permissions. how do i fix this?
Hi @shamith-smp-dgt , first you need to make sure your AuthServiceProvider.php is registered. To do this add the provider to the bootstrap/providers.php file.
Then when defining your gate in the AuthServiceProvider, you need to use these abilities for list - access-module-list and access-media-library because Twill 3 now uses them. You can find that here
or you can just extend the Twill AuthServiceProvider and used the already defined methods to achieve the same purpose
<?php
namespace App\Providers;
use App\Models\Enums\UserRole;
use A17\Twill\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
public function boot()
{
$this->define('list', function ($user, $item = null) {
return $this->authorize($user, function ($user) {
return $this->userHasRole($user, [
...
UserRole::VIEWER,
]);
});
});
}
}
Description
Hello, I'm trying to create new roles and add permissions to them. i want to make some modules only accessible by some of the new roles I've created. I followed the twill documentation and I still get Forbidden yellow screen error when i try to access a certain module as the new user role i created.
It looks like the code in AuthServiceProvider is not redefining twill's default permissions. how do i fix this?
Steps to reproduce
here is my code,
Models/Enums/UserRole.php
Providers/AppServiceProvider.php
Providers/AuthServiceProvider.php
Expected result
When i logged in as a VIEWER and visit a module, I should be able to see it.
Actual result
But a I get a Forbidden yellow screen error.
Versions
Twill version: 3.4
Laravel version: 11.9
PHP version: 8.2
Database engine: MySQL
The text was updated successfully, but these errors were encountered: