Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions config/websockets.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use BeyondCode\LaravelWebSockets\Dashboard\Http\Middleware\Authorize;

return [

/*
Expand Down Expand Up @@ -47,6 +49,18 @@
*/
'path' => 'laravel-websockets',

/*
* Dashboard Routes Middleware
*
* These middleware will be assigned to every dashboard route, giving you
* the chance to add your own middleware to this list or change any of
* the existing middleware. Or, you can simply stick with this list.
*/
'middleware' => [
'web',
Authorize::class,
],

'statistics' => [
/*
* This model will be used to store the statistics of the WebSocketsServer.
Expand Down
2 changes: 1 addition & 1 deletion src/Dashboard/Http/Middleware/Authorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class Authorize
{
public function handle($request, $next)
{
return Gate::check('viewWebSocketsDashboard') ? $next($request) : abort(403);
return Gate::check('viewWebSocketsDashboard', [$request->user()]) ? $next($request) : abort(403);
}
}
4 changes: 2 additions & 2 deletions src/WebSocketsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function register()
protected function registerRoutes()
{
Route::prefix(config('websockets.path'))->group(function () {
Route::middleware(AuthorizeDashboard::class)->group(function () {
Route::middleware(config('websockets.middleware', [AuthorizeDashboard::class]))->group(function () {
Route::get('/', ShowDashboard::class);
Route::get('/api/{appId}/statistics', [DashboardApiController::class, 'getStatistics']);
Route::post('auth', AuthenticateDashboard::class);
Expand All @@ -79,7 +79,7 @@ protected function registerRoutes()

protected function registerDashboardGate()
{
Gate::define('viewWebSocketsDashboard', function ($user = null) {
Gate::define('viewWebSocketsDashboard', function ($user) {
return app()->environment('local');
});

Expand Down