CodeIgniter Forums

Full Version: Myth Auth LoginFilter Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Does anyone here encountered this issue as mine?

PHP Code:
[b]Fatal error[/b]: Declaration of Myth\Auth\Filters\LoginFilter::before(CodeIgniter\HTTP\RequestInterface $requestmust be compatible with CodeIgniter\Filters\FilterInterface::before(CodeIgniter\HTTP\RequestInterface $request$arguments NULLin [b]/var/www/charlzsys/vendor/myth/auth/src/Filters/LoginFilter.php[/bon line [b]24[/b

PHP Code:
$routes->group('', ['filter' => 'login'], function($routes) {

PHP Code:
<?php namespace Config;


Filters extends BaseConfig
// Makes reading things below nicer,
    // and simpler to change out script that's used.
public $aliases = [
'csrf'     => \CodeIgniter\Filters\CSRF::class,
'toolbar'  => \CodeIgniter\Filters\DebugToolbar::class,
'honeypot' => \CodeIgniter\Filters\Honeypot::class,
'login'      => \Myth\Auth\Filters\LoginFilter::class,
        'role'       => \Myth\Auth\Filters\RoleFilter::class,
        'permission' => \Myth\Auth\Filters\PermissionFilter::class,

// Always applied before every request
public $globals = [
'before' => [
            // 'csrf',
'after'  => [

// Works on all of a particular HTTP method
    // (GET, POST, etc) as BEFORE filters only
    //     like: 'post' => ['CSRF', 'throttle'],
public $methods = [];

// List filter aliases and any before/after uri patterns
    // that they should run on, like:
    //    'isLoggedIn' => ['before' => ['account/*', 'profiles/*']],
public $filters = [];

Did you download the newest Myth/Auth and CodeIgniter both have been updated.
(09-13-2020, 08:19 AM)InsiteFX Wrote: [ -> ]Did you download the newest Myth/Auth and CodeIgniter both have been updated.

Yes both are updated with latest builds.
Did you add all the settings to the files?

Restrict routes based on their URI pattern by editing app/Config/Filters.php and adding them to the $filters array, e.g.:

PHP Code:
public filters = [
    'login' => ['before' => ['account/*']],

Or restrict your entire site by adding the LoginFilter to the $globals array:

PHP Code:
    public $globals = [
        'before' => [

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:

PHP Code:
$routes->get('admin/users''UserController::index', ['filter' => 'permission:manage-user'])
$routes->get('admin/users''UserController::index', ['filter' => 'role:admin,superadmin']) 

The filter can be either role or permission, which restricts the route by either group or permission.
You must add a comma-separated list of groups or permissions to check the logged in user against.

Restricting Route Groups

In the same way, entire groups of routes can be restricted within the group() method:

PHP Code:
$routes->group('admin', ['filter' => 'role:admin,superadmin'], function($routes) {
Yes i did it already, and it is now working. Though i have a new issue on it. Whenever i logged with my username and password, the auth is not working, i have checked the database auth_login table and it was successfully logged in but upon checking on the CI dev toolbar the Auth says ¨Not logged in¨ and i cannot push through to the index page.
Check you session data to see what it says you could be over write or clearing it some place.
Here is what i see on my session data:

Session User Data
__ci_last_regenerate 1600175570
That's strange because I'' am using it on my blog login and it redirects me to login then to my front page.

But I have mine on the route not the group route.
Yeah it is really strange for me also, i tried to reinstall from scratch both CI 4.0.4 and myth-auth and still it is not working. here's the screen record of mine: