Welcome Guest, Not a member yet? Register   Sign In
Filter's dont work
#11

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 
Reply
#12

(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
Reply
#13

(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

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

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 
[font=Monaco, Consolas, Courier, monospace]$routes->add('Controller_name','filter' => 'adminFiltersNoAuth']);
[/font]
?
Reply
#14

(12-06-2020, 02:27 AM)pippuccio76 Wrote: The answer is : 
Can i redirect every method of controller if the user/admin  isn't logged write only one row f.e 
[font=Monaco, Consolas, Courier, monospace]$routes->add('Controller_name','filter' => 'adminFiltersNoAuth']);
[/font]
?
My guess is that you need to use $routes-group() for that.
Reply
#15

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 )
Reply
#16

(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  Big Grin , therefore in ci 3 with few row inside the construct :

if(!isset($_SESSION['is_admin'])){
redirect('/admin/login', 'refresh');
}


now i must write a row for every controller's method....
Reply
#17

(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  Big Grin , therefore in ci 3 with few row inside the construct :

if(!isset($_SESSION['is_admin'])){
redirect('/admin/login', 'refresh');
}


now i must write a row for every controller's method....

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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB