Prevent access using spatie permissions #16
Replies: 7 comments 7 replies
-
Great post @snapey ! 👏 Added some links to the Spatie's package for easier navigation 😄 |
Beta Was this translation helpful? Give feedback.
-
I absolutely love the package middlewares provided by spatie/laravel-permission If you have the package middlewares setup already, then you can easily use them in the log viewer route middleware. Here is permalink to the doc: https://spatie.be/docs/laravel-permission/v5/basic-usage/middleware#content-package-middleware So using something like |
Beta Was this translation helpful? Give feedback.
-
easy and simple . thanks
|
Beta Was this translation helpful? Give feedback.
-
how to set the token in the blade file?
|
Beta Was this translation helpful? Give feedback.
-
Hi, Just add this to
|
Beta Was this translation helpful? Give feedback.
-
I did everything in here, but in production, it always redirects to homepage, but in localhost, it works. Logs are empty. Maybe there's a special settings on production? Thanks |
Beta Was this translation helpful? Give feedback.
-
@snapey |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I offer a solution for protecting the logs using Spatie's Laravel Permissions package;
Create a permission
For instance 'view-logs'. User will need this permission, or a role that provides this permission to access the logs.
Learn how to set up permissions
Create a middleware
app\Http\MiddlewareViewLogs.php
Create a name for this middleware
In app\Http\Kernel.php
Add the following to $routeMiddleware array
Add middleware to the the log viewer config
Beta Was this translation helpful? Give feedback.
All reactions