Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter Config not quite working with Routes? #2037

Closed
Pantoflarz opened this issue Jun 4, 2019 · 4 comments
Closed

Filter Config not quite working with Routes? #2037

Pantoflarz opened this issue Jun 4, 2019 · 4 comments

Comments

@Pantoflarz
Copy link

Pantoflarz commented Jun 4, 2019

It feels like there is very little proper documentation on these filters.
They are a very good addon, but a little clarification would be good.

We have a filter, sessioncheckGlobal which deals with making sure that a user is logged in prior to accessing a webpage. The config for this filter is the following:

public $globals = [
		'before' => [
			'sessioncheckGlobal' => ['except' => ['maintenance', 'browseroutofdate', 'login', 'logout', 'website']],
		],
		'after'  => [
			'toolbar',
		],
	];

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:

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

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

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

More routes if it helps:

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

My understanding is that this filter should only run on website.com/login and not website.com/admin/login (if I wanted this behaviour, I should put "*/login" instead, right?)

Just in case it makes it any easier, our Controller structure:

Controllers
- Admin
      - Dashboard
      - Login
- Dashboard
      - Dashboard
      - Login
- Website
      - Website

Running CodeIgniter 4.0.0-beta.3
on PHP 7.3.5-1+ubuntu16.04.1+deb.sury.org+1

I know the way I've explained is very confusing but I've been sat looking at this all day and I'm going a bit crazy. Any better documentation or explanation would help, though I am not sure if its an issue with our configs or the actual framework.

Thanks

@lonnieezell
Copy link
Member

This is asking for help, not filing a bug. For help, please use our forums.

Luckily, one of your friends has already opened a thread there.

@Pantoflarz
Copy link
Author

This is showing you incorrect behaviour of a feature - exactly what I consider to be a bug.

@lonnieezell
Copy link
Member

Right - but your initial post was "I'm not sure if this is a bug or if we're not doing it right." Which means you're asking for help. A bug report is "If I do X, then Y happens" and it should do "Z", with easily reproducible steps. Your post did reveal one bug with the login route which was fixed last night, but I was unable to replicate the primary thing you were asking for help on.

See the forum for more details.

@AkashKrx
Copy link

@Pantoflarz Have you found a fix for this. I also checked the linked forum post didn't find a fix there either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants