Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: #9

Open
ifdancoder opened this issue Nov 18, 2024 · 0 comments
Open

[Bug]: #9

ifdancoder opened this issue Nov 18, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ifdancoder
Copy link

ifdancoder commented Nov 18, 2024

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

@ifdancoder ifdancoder added the bug Something isn't working label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant