CodeIgniter Forums
Myth Auth LoginFilter Problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Myth Auth LoginFilter Problem (/showthread.php?tid=77541)

Pages: 1 2


Myth Auth LoginFilter Problem - ralphcabanero - 09-13-2020

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

app/config/Routes.php
PHP Code:
$routes->group('', ['filter' => 'login'], function($routes) {
    
$routes->get('/''Home::index');
    
$routes->get('home''Home::index');
    
    
$routes->get('/test''Home::test');
}); 

app/config/Filters.php
PHP Code:
<?php namespace Config;

use 
CodeIgniter\Config\BaseConfig;

class 
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' => [
            
//'honeypot',
            // 'csrf',
            //'auth',
        
],
        
'after'  => [
            
'toolbar',
            
//'honeypot'
        
],
    ];

    
// 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 = [];




RE: Myth Auth LoginFilter Problem - InsiteFX - 09-13-2020

Did you download the newest Myth/Auth and CodeIgniter both have been updated.


RE: Myth Auth LoginFilter Problem - ralphcabanero - 09-13-2020

(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.


RE: Myth Auth LoginFilter Problem - InsiteFX - 09-13-2020

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' => [
            'honeypot',
            'login'

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) {
    ...
}); 



RE: Myth Auth LoginFilter Problem - ralphcabanero - 09-14-2020

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.


RE: Myth Auth LoginFilter Problem - InsiteFX - 09-14-2020

Check you session data to see what it says you could be over write or clearing it some place.


RE: Myth Auth LoginFilter Problem - ralphcabanero - 09-15-2020

Here is what i see on my session data:

Session User Data
__ci_last_regenerate 1600175570
redirect_url http://192.168.254.202:83/login
_ci_previous_url http://192.168.254.202:83/login


RE: Myth Auth LoginFilter Problem - InsiteFX - 09-15-2020

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.


RE: Myth Auth LoginFilter Problem - ralphcabanero - 09-15-2020

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: https://drive.google.com/file/d/1foGzlnm0aASx93olpMHjf3rCpApb9705/view


RE: Myth Auth LoginFilter Problem - raajaud - 12-01-2020

(09-14-2020, 04:46 AM)ralphcabanero Wrote: 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.
How you solved the issue, plz share.. I'm facing the same issue.