Skip to content

[Bug]:  #9

@ifdancoder

Description

@ifdancoder

What happened?

Hi! Should we use this registration

    $panel->middleware([
        config('password-expiry.password_expiry_middleware', PasswordExpiryMiddleware::class),
    ]);

instead of

    $panel->middleware([
        PasswordExpiryMiddleware::class
    ]);

and also should we pass jsonresponses through the middleware as in the example

    public function handle(Request $request, Closure $next): Response | RedirectResponse
    {
        if (
            $this->passwordHasExpired() &&
            !$request->routeIs(PasswordExpiry::getPasswordExpiryRoute()) &&
            !$request->routeIs('*.auth.*')
        ) {
            return redirect(route(PasswordExpiry::getPasswordExpiryRoute()));
        }
    
        $response = $next($request);
    
        if ($response instanceof JsonResponse) {
            return response($response->getContent(), $response->getStatusCode(), $response->headers->all());
        }
    
        return $response;
    }

instead of

    public function handle(Request $request, Closure $next): Response | RedirectResponse
    {
        if (
            $this->passwordHasExpired() &&
            !$request->routeIs(PasswordExpiry::getPasswordExpiryRoute()) &&
            !$request->routeIs('*.auth.*')
        ) {
            return redirect(route(PasswordExpiry::getPasswordExpiryRoute()));
        }

        return $next($request);
    }

?

Currently I have a problem that middleware in my plugin does not work. But when I use the proposed registration, it works.

How to reproduce the bug

You should try to set custom class in config + try to pass JsonResponse through the middleware

Package Version

3.0

PHP Version

8.3

Laravel Version

11.0

Which operating systems does with happen with?

No response

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions