Search code examples
phpcodeigniter-4

Override default Myth\Auth Route library in Codeigniter 4


need your help

i using Myth\Auth and want to seprating auth route for admin and front user cause there are different ways to login between both with different controller, but when i try to set in my config route like this :

$routes->group('', function($routes) {

    // Login/out
    $routes->get('login', 'AuthInformerController::login', ['as' => 'app-login']);
    $routes->post('login', 'AuthInformerController::attemptLogin');
    $routes->get('logout', 'AuthInformerController::logout');

    // Registration
    $routes->get('register', 'AuthInformerController::register', ['as' => 'app-register']);
    $routes->post('register', 'AuthInformerController::attemptRegister');

});

but this config not override default Route in \Myth\Auth\Config, How The way to override default route like this ?

There is my Routes Files

thanks for advice !


Solution

  • its will done with disable routes in config/modules.php :

    public $aliases = [
            'events',
            'filters',
            'registrars',
            'routes',
            'services',
        ];
    

    comment 'routes' in array make routes for all module not be autoload anymore, so you can manually define in your own routes.

    public $aliases = [
            'events',
            'filters',
            'registrars',
            //'routes',
            'services',
        ];