Welcome Guest, Not a member yet? Register   Sign In
Filter controller without authentication
#4

PHP Code:
.app/Config/Filters.php

// Add to the aliases section.
'login'      => \YourNameSpace\YourFolder\Filters\YourFilterName::class,

// Or restrict your entire site by adding the LoginFilter to the $globals array:
public $globals = [
    'before' => [
        //'honeypot'
        // 'csrf',
    
'login',
    ],
    'after'  => [
        'toolbar',
        //'honeypot'
    ],
];

Restricting a single route:

// Any single route can be restricted by adding the filter option to the last parameter in any of the route definition methods:
$routes->get('admin/users''UserController::index', ['filter' => 'permission:manage-user']);

Restricting Route Groups:

// In the same way, entire groups of routes can be restricted within the group() method:
$routes->group('admin', ['filter' => 'role:admin,superadmin'], function($routes) {
    ...
}); 

A lot of this is from Myth/Auth, I suggest that you download it and go through the code.

Myth:Auth
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
RE: Filter controller without authentication - by InsiteFX - 08-25-2020, 08:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB