Filter's dont work |
so it's no possible write only one row for every controller's method ? In ci3 i insert the control in constructor ( control if isset a session variable) but seem not working in ci4
OFFTOPIC: Matleyx ti ho inviato dei privati ma forse non li hai letti (12-05-2020, 01:48 AM)pippuccio76 Wrote: so it's no possible write only one row for every controller's method ? In ci3 i insert the control in constructor ( control if isset a session variable) but seem not working in ci4 As I understand it you are asking two questions: 1) one row for each controller method? Yes, you can do: PHP Code: $routes->post('example', 'Controller\example'); 2) control in constructor in CI4 I understand the pain - in CI3 I used the constructor to check for access and bailed out if no access. For CI4 you should look into Controller before Filters instead - https://codeigniter4.github.io/userguide...re-filters Also, in CI4, the constructor of a controller is replaced with initController - https://codeigniter4.github.io/userguide...oller.html
(12-05-2020, 02:01 AM)tgix Wrote:(12-05-2020, 01:48 AM)pippuccio76 Wrote: so it's no possible write only one row for every controller's method ? In ci3 i insert the control in constructor ( control if isset a session variable) but seem not working in ci4 The first and second are for the same purpose , redirect if the user/admin isn't logged ... The answer is : Can i redirect every method of controller if the user/admin isn't logged write only one row f.e $routes->add('Controller_name','filter' => 'adminFiltersNoAuth']); ?
Correct if you apply a Filter to a group from what I have done it doe's apply to all routes under that group.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(12-06-2020, 07:40 AM)InsiteFX Wrote: Correct if you apply a Filter to a group from what I have done it doe's apply to all routes under that group.My english is poor i understand ![]() if(!isset($_SESSION['is_admin'])){ redirect('/admin/login', 'refresh'); } now i must write a row for every controller's method.... (12-06-2020, 10:11 AM)pippuccio76 Wrote:(12-06-2020, 07:40 AM)InsiteFX Wrote: Correct if you apply a Filter to a group from what I have done it doe's apply to all routes under that group.My english is poor i understand use controller filter for that, no need to duplicate the check on each methods documentation link = https://codeigniter.com/user_guide/incom...ght=filter watch for tutorial here = https://www.youtube.com/watch?v=5DLgPldkQxc&t=774s |
Welcome Guest, Not a member yet? Register Sign In |