CodeIgniter Forums
Filters in route not working in codeigniter 4.0.4 - 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: Filters in route not working in codeigniter 4.0.4 (/showthread.php?tid=77121)



Filters in route not working in codeigniter 4.0.4 - seunex - 07-21-2020

Filter in route does not look to work this filter isLogged if i use it in GLobal filters it works but if use it in a specific route is does not effect at all

The function as no effect at all.
PHP Code:
$routes->get('upload''ItemUploadController::chooseCategory', ['filter' => 'isLogged''as' => 'userUploadItemStart']); 



RE: Filters in route not working in codeigniter 4.0.4 - captain-sensible - 07-21-2020

i'm using 4.0.4 and filter works on a specific route.


But i put my filter class in app/Filters directory.

Then i edit app/Config/Filters.php

eg

Code:
    public $aliases = [


'myfilter3'=> \App\Filters\MyFilter3::class,


......

public $filters = [
    



'myfilter3' => ['before' => ['removeBlog']],


//the nitty gritty of MyFilter3.php is

  session_start();
  $logic=isset($_SESSION['role']) ;

{
//logic

}



RE: Filters in route not working in codeigniter 4.0.4 - seunex - 07-21-2020

Filters work fine while using it in filter.php am talking about using it in a specific route


RE: Filters in route not working in codeigniter 4.0.4 - captain-sensible - 07-23-2020

How specific is "specific" the code

Code:
'myfilter3' => ['before' => ['removeBlog']],
only works on this route :
Code:
$routes->get('removeBlog','Blog::delBlogForm');