Might seem like a dumb question, but I created this filter below, I am using Shield, I want the user to be redirected when accessing a protected controller. Right now it redirects to /login. and I want it to go to /pages/view/Login
I added this filter, but how do I use it?
Code:
<?php
namespace App\Filters;
use CodeIgniter\Filters\FilterInterface;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
class LoggedIn implements FilterInterface
{
public function before(RequestInterface $request, $arguments = null)
{
$auth = service('auth');
if (!$auth()->loggedIn()) {
return redirect()->to(site_url('pages/view/Login'));
}
}
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
}
}
Ok I just added it as an alias,
Code:
public array $aliases = [
'csrf' => CSRF::class,
'toolbar' => DebugToolbar::class,
'honeypot' => Honeypot::class,
'invalidchars' => InvalidChars::class,
'secureheaders' => SecureHeaders::class,
'LoggedIn' => \App\Filters\LoggedIn::class,
];
Then added a filter like below, and that works.
Code:
'LoggedIn' => ['before' => ['dashboard', 'dashboard/*']],