Welcome Guest, Not a member yet? Register   Sign In
Shield Route Filtering via group
#1

I have the following lines in my Config/Routes.php:
PHP Code:
$routes->get('/''Home::index');

$routes->resource('api/clients', [
    'controller' => 'API\Clients',
    'only' => ['index''create'],
    'filter' => 'group:admin,superadmin',
]);
$routes->presenter('clients', [
    'controller' => 'Clients',
    'only' => ['index'],
    'filter' => 'group:admin,superadmin',
]);

service('auth')->routes($routes); 

The public string $defaultGroup = 'user'; in Config/AuthGroups.php for a newly registered user is unchanged. However, when I navigate to http://localhost/clients (with a user in the default group) I can still see and interact with the page just fine. I confirmed the group alias filter is being applied to the route by using php spark filter:check GET /clients. It generated the following:
Code:
+--------+----------+----------------+---------------+
| Method | Route    | Before Filters | After Filters |
+--------+----------+----------------+---------------+
| GET    | /clients | group session  | group toolbar |
+--------+----------+----------------+---------------+

So the filter is being applied, but the arguments of admin,superadmin do nothing to filter a member of the user group. What am I doing wrong?
Reply
#2

Hi,
Unfortunately, I could not reproduce your problem.


.jpg   filter.jpg (Size: 69.42 KB / Downloads: 10)

So if I need to provide more details to reproduce your problem.
Maybe sharing the output of the following commands or anything else, including the framework version and...

Code:
php spark db:table auth_groups_users&php spark db:table users
Reply
#3

I'm not sure what happened either. I haven't made any changes to the code; yet today I spun up the docker image and everything worked. I guess I must've been logged in with an admin user, or some sort of caching was happening in the browser. I really can't explain it. Regardless, thank you for your help datamweb.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB