Welcome Guest, Not a member yet? Register   Sign In
Controller filter does not work in the default controller
#1

(This post was last modified: 03-15-2020, 06:54 AM by nacio.)

Hi, I created a controller filter that checks if the user is logged in, but it doesn't work in the default controller (Home.php in this case).

It also happens that it doesn't work in any index method unless you put it also without the asterisk('user/*', 'user/').

Thank you and I appreciate a reply.

This is how I got it:

// List filter aliases and any before/after uri patterns
// that they should run on, like:

//    'isLoggedIn' => ['before' => ['account/*', 'profiles/*']],
    public $filters = [
        'isLoggedIn' => ['before' => [ 'user/*''user/','home/*']],
Reply
#2

Hello, I had the same problem.
`user/*` means the filter to be applied on any other URIs after user/.

To include `user`, do the following:

`public $filters = [
'isLoggedIn' => ['before' => [ 'user*', 'home*']],
]`

Note, there is no forward-slash before the *.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB