'Problems with CI4 filter

I'm trying to apply an 'Except' rule on all methods of my controller use, but it is not working; it's stucks in a loop "ERR_TOO_MANY_REDIRECTS."

public $globals = [
    'before' => [
        'notAuth' => ['except' => 'auth/*'],
        // 'honeypot',
        // 'csrf',
        // 'invalidchars',
    ],
    'after' => [
        'toolbar',
        // 'honeypot',
        // 'secureheaders',
    ],
];

Filters.php

use App\Filters\Auth\NotAuthFilter;

public $aliases = [
    'csrf' => CSRF::class,
    'toolbar' => DebugToolbar::class,
    'honeypot' => Honeypot::class,
    'invalidchars' => InvalidChars::class,
    'secureheaders' => SecureHeaders::class,
    'notAuth' => NotAuthFilter::class,
];

The filter

class NotAuthFilter implements FilterInterface
{
    public function before(RequestInterface $request, $arguments = null)
    {
        // Verifica se o usuário possui uma sessão válida
        if (!session()->has('logged_in')) {
            return redirect()->to('auth?back='.uri_string());
        }
    }

    public function after(RequestInterface $request, 
        ResponseInterface $response, $arguments = null)
    {
        // Do something here
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source