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

seems web middleware not called #406

Open
MattiaMarchiorato opened this issue Dec 11, 2024 · 2 comments
Open

seems web middleware not called #406

MattiaMarchiorato opened this issue Dec 11, 2024 · 2 comments

Comments

@MattiaMarchiorato
Copy link

MattiaMarchiorato commented Dec 11, 2024

Hello,

is project upgraded to laravel 11 form 10 recently, we tried to install the package, we add the LogViewer::auth in the AppServiceProvider but when we hit the url http://127.0.0.1:8081/log-viewer seems the $request->user() is empty.

LogViewer::auth(function ($request) {
 return $request->user()->isAdmin();
});
 'middleware' => [
        'web',
        \Opcodes\LogViewer\Http\Middleware\AuthorizeLogViewer::class,
],
APP_URL=http://127.0.0.1:8081

We also tried with the gate but with the same issue.

With a dd

        LogViewer::auth(function ($request) {
            dd($request->user()->isAdmin());
            return $request->user()->isAdmin();
        });

we receive true

Thanks

@MattiaMarchiorato
Copy link
Author

Adding a custom middleware 'admin'

'middleware' => [
        'web',
        'admin'
 ],

is working, but is very strange that is not working with the LogViewer::auth

@MattiaMarchiorato
Copy link
Author

LogViewer::auth(function ($request) {
            Log::info(['user request', $request->user()]);
            Log::info(['user auth', Auth::user()]);
            return true;
});
Screenshot 2024-12-11 alle 17 12 42

With some logging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant