bakerkretzmar / nova-settings-tool

Laravel Nova tool to view and edit application settings.
MIT License
167 stars 32 forks source link

Insert middleware Authenticate::class #53

Closed leonardyrj closed 1 year ago

leonardyrj commented 1 year ago

I really liked your package, but I needed to have the Authenticate::class middleware in the request. Is there any problem to include in Route::middleware?

Nova::router(['nova', Authorize::class], 'settings') ->group(__DIR__ . '/../routes/inertia.php');

bakerkretzmar commented 1 year ago

I don't understand what you're asking here—do you want me to add the Authenticate middleware in this package? Or are you just wondering if you can do it yourself?

leonardyrj commented 1 year ago

if you can add

bakerkretzmar commented 1 year ago

Okay gotcha. What exactly are you trying to do? Nova handles authentication (whether the user is logged in) for you, and the Authenticate middleware should already be active on all Nova routes. Check the middleware array in your nova.php config file, and if it's not there, you can add it there yourself.

The Authorize middleware included in this package already let's you use any of Nova/Laravel's authorization (what the user is allowed to do) features.

Let me know if that solves your problem.

leonardyrj commented 1 year ago

I need to get the instance of the authenticated user ex: $request->auth(). When access to your tool returns null

bakerkretzmar commented 1 year ago

Where exactly are you running $request->user()? Please include the actual code.

leonardyrj commented 1 year ago

https://nova.laravel.com/docs/4.0/customization/menus.html

$menu->prepend( MenuItem::make( 'My Profile', "/resources/users/{$request->user()->getKey()}" ) );

I'm creating a custom menu, when I access your tool it gives an error in request->user. Test it for you to see the error

bakerkretzmar commented 1 year ago

That doesn't look like it has anything to do with this package, what makes you think it's related? Can you please share the full output of the error and the complete code sample causing the error?

bakerkretzmar commented 1 year ago

Pretty sure this isn't an issue with this package, looks similar to #52. Feel free to comment again if you have more information to add or can reproduce/isolate this!