• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Filter config not working with routes (?)

#1
Basically, I have a filter called "sessionCheckGloba", which deals with making sure that a user is logged in prior to accessing a webpage. The config for this filter is the following:

PHP Code:
public $globals = [
    
'before' => [
        
'sessioncheckGlobal' => ['except' => ['maintenance''browseroutofdate''login''logout''website']],
    ]
]; 


Where 'website' is in the exception list, it doesn't work.
Neither does '' (a blank element) or '/' (which stops the filter running at all).


So I guess the first question is, how do you make a filter not run on the main page where the main page is configured as the default controller?

In our case, the default controller is app/Controllers/Website/Website.php and the App is configured to route in this way:

Code:
$routes->get('/', 'Website/Website::index');

Second question, why does the following config make logincheck run on /admin/login ?

Code:
public $filters = [
    'loginfilter' => ['before' => ['login']],
];

In case, some more routes:

Code:
$routes->get('/login', 'Dashboard/Login::index');
$routes->get('/admin/login', 'Admin/Login::index');

My friend has created a similar question on GitHub but I feel like a lot of people use the forums and not GitHub.

Thanks.
Reply

#2
Thanks for posting here. We do not provide support through GitHub only here, so that was the right thing to do. Smile

Does anything show up in the logs? It sounds like an error is being repressed. Does the route still display like normal or does it go to a blank screen?

I'll start with the easy one: There does appear to be a bug with the login or admin/login that is not requiring that string to be at the beginning. Should be a relatively simple fix.

As for the weird issue you're seeing with the Website controller - I'm unable to duplicate. I set things up as closely as I could, though used App\Controllers\Website\Website so that I didn't have to setup a new namespace. Played with several variations of assigning the filter and it seemed to work correctly. Both with and without the fix I found for the other issue.

Can you replicate in any other way out of the box with generic install of CodeIgniter? You may need to follow the code through a bit, which should be in either CodeIgniter.php or Filters/Filters.php.
Support Development  • Practical CodeIgniter 3  • Vulcan - CLI Tools for CI4
Reply

#3
About your first question, my logs are completely empty.

As for the second question, yes, I created a clean version of CodeIgniter, and still had the same issue.
Reply

#4
(06-03-2019, 08:13 PM)kilishan Wrote: Does anything show up in the logs? It sounds like an error is being repressed. Does the route still display like normal or does it go to a blank screen?

Logs are completely empty and by that I mean that log level is set to 9 and permissions set to the writable directory, but no log file is ever created. Route still displays as normal (in our case it redirects to another part of the website because if user is not authenticated then he should login first - intended behaviour).

We tried on an empty install yesterday with just two controllers and the same behaviour still appeared.

Is 'website' the correct exception to configure? From my understanding, the except list should contain URI's, but surely if the website is configured to point to the default controller, then website.com is what shows up in the browser, the URI is actually blank bar the domain - i.e. there is nothing after website.com. But as mentioned here setting "" or "/" doesn't work either.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.