Welcome Guest, Not a member yet? Register   Sign In
Except in Filters
#1

(This post was last modified: 06-06-2022, 11:11 PM by SubrataJ.)

Hi There,

I hope you guys are having a fantastic day.

I was wondering if there is any way to exclude some URLs from an Authfilter.

PHP Code:
public $filters = [
        
'adminAuth' => [
            
'before' => [
                
'admin/*'
            
],
            
'except' => [
                
'admin/forgot-password',
            ],
        ],
    ]; 

have tried this, but it seems not working.

(06-06-2022, 10:54 PM)SubrataJ Wrote: Hi There,

I hope you guys are having a fantastic day.

I was wondering if there is any way to exclude some URLs from an Authfilter.

PHP Code:
public $filters = [
        'adminAuth' => [
            'before' => [
                'admin/*'
            ],
            'except' => [
                'admin/forgot-password',
            ],
        ],
    ]; 

have tried this, but it seems not working.


Thanks, I got the solution I guess

instead of setting rules on public $filters, I have done this way and it seems working fine, code is given below

PHP Code:
public $globals = [
        'before' => [
            'adminAuth' => [
                'except' => [
                    'admin/forgot-password',
                    'admin'//my login uri
                    'service-providers/*' //begin URI segment of my frontend 
                ],
            ],
        ],
        'after' => [
            'toolbar',
            // 'honeypot',
            // 'secureheaders',
        ],
    ]; 


I still wanna know the correct way to do it or if there's any better way to get it done or if there are any possibilities we can do it inside public $filters.
Reply
#2

Please read this, but focus on $globals

CodeIgniter User Guide -> Controller Filters
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(This post was last modified: 06-06-2022, 11:21 PM by kenjis.)

$filters does not have `except`. If you use $filters, you must list all URI patterns to be protected.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB