lonnieezell / myth-auth

One-stop Auth package for CodeIgniter 4
MIT License
633 stars 206 forks source link

filters don't redirect #260

Closed gitchak closed 4 years ago

gitchak commented 4 years ago

All works except the filters. I add the below.

public filters = [ 'login' => ['before' => ['admin/*']], ];

Now my "admin" controller loads with out getting redirected to login. If do a manual check from the controller as below it works.

if(!logged_in()){ return redirect('login'); }

Would love to get the filters working. Please help.

MGatner commented 4 years ago

What is your actual route? admin/* won’t match admin - try admin* instead

gitchak commented 4 years ago

my actual route is "http://localhost:8080/admin". admin* gives me a error "VENDORPATH\myth\auth\src\Filters\LoginFilter.php at line 8"

MGatner commented 4 years ago

You didn’t share the error message, but it sounds like the corrected route is actually running the filter now. My guess is that you are on an outdated version of the framework that is missing the FilterInterface. Try updating and running again.

gitchak commented 4 years ago

I'm on Ci - 4.0.4. Did run update from composer. Below is the full error.

ErrorException #64 Declaration of Myth\Auth\Filters\LoginFilter::before(CodeIgniter\HTTP\RequestInterface $request) must be compatible with CodeIgniter\Filters\FilterInterface::before(CodeIgniter\HTTP\RequestInterface $request, $arguments = NULL)

much appreciate your support MGatner.

MGatner commented 4 years ago

Ah, yes. The issue wasn’t the framework, your Myth:Auth is outdated. See this issue: https://github.com/lonnieezell/myth-auth/issues/253

gitchak commented 4 years ago

"dev-develop" update did the trick. Thank you so much MGatner.