CodeIgniter Forums
does not automatically redirect for the use of modules. - 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: does not automatically redirect for the use of modules. (/showthread.php?tid=88985)



does not automatically redirect for the use of modules. - mywebmanavgat - 12-17-2023

Even if I follow the documentation, the core tries to find it in the default namespaces.

I defined $moduleRoutes in the roiting.php file. but still failed.


[Video: https://www.youtube.com/watch?v=eFxTE1T-UGc]


RE: does not automatically redirect for the use of modules. - kenjis - 12-17-2023

Try this: https://github.com/kenjis/ci4-modules-test/commit/b2d6230aa1d9bcd58b73dbfa34b0efe51aa45eb1


RE: does not automatically redirect for the use of modules. - mywebmanavgat - 12-18-2023

(12-17-2023, 04:15 AM)kenjis Wrote: Try this: https://github.com/kenjis/ci4-modules-test/commit/b2d6230aa1d9bcd58b73dbfa34b0efe51aa45eb1

I applied the changes but

I keep getting the error No controller is found for: login.

You can download here my empty ci4 Project : https://s6.dosya.tc/server17/lb8trr/ci4.zip.html


RE: does not automatically redirect for the use of modules. - kenjis - 12-18-2023

PHP Code:
<?php
namespace Login\Controllers;
use 
App\Controllers\BaseController;
class 
Login extends BaseController
{
 public function 
__construct()
 {
 
parent::__construct();
 
$this->template->setContentViewPath('Login\Views');
 }
 public function 
getIndex()
 {
 
$data = [];
 
$this->template->set('title','Başlık');
 
$this->template->content('blog_view',$data);
 
$this->template->publish();
 }



Quote:Important
A controller method that will be executed by Auto Routing (Improved) needs HTTP verb (get, post, put, etc.) prefix like getIndex(), postCreate().
https://codeigniter4.github.io/CodeIgniter4/incoming/controllers.html#let-s-try-it-hello-world



RE: does not automatically redirect for the use of modules. - mywebmanavgat - 12-18-2023

This makes sense but isn't it ridiculous to make it mandatory? Ci3 was really great with everything, but I have to switch to ci4 because I'm not sure if there will be updates for the new php versions.

When I download your project, it works. but when I do it myself step by step, I get an error. anyway, no problem, I will go over it. thank you for your help.


RE: does not automatically redirect for the use of modules. - kenjis - 12-18-2023

Adding the HTTP method to the controller's method name is mandatory.
Without this, a large number of vulnerabilities would be created that would allow controller filters to be bypassed.

Legacy auto routing can also be used in CI4, but is not recommended.

CI3 does not have controller filters, so they cannot be bypassed, but I am not sure that CI3's auto routing is truly secure.
An attack might be possible if the site is accessed by an HTTP method that the developer does not anticipate.