Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit c050fe8

Browse files
committed
wip
1 parent 09396cd commit c050fe8

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/Apps/App.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static function findByKey(string $appKey): ?App
3636

3737
public static function findBySecret(string $appSecret): ?App
3838
{
39-
return app(AppProvider::class)->findByKey($appSecret);
39+
return app(AppProvider::class)->findBySecret($appSecret);
4040
}
4141

4242
public function __construct($appId, string $appKey, string $appSecret)

src/WebSocketsServiceProvider.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\DashboardApiController;
77
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\SendMessage;
88
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\ShowDashboard;
9-
use BeyondCode\LaravelWebSockets\Dashboard\Http\Middleware\Authorize;
9+
use BeyondCode\LaravelWebSockets\Dashboard\Http\Middleware\Authorize as AuthorizeDashboard;
10+
use BeyondCode\LaravelWebSockets\Statistics\Http\Middleware\Authorize as AuthorizeStatistics;
1011
use BeyondCode\LaravelWebSockets\Server\Router;
1112
use BeyondCode\LaravelWebSockets\Statistics\Http\Controllers\WebSocketStatisticsEntriesController;
1213
use BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger;
@@ -62,14 +63,16 @@ public function register()
6263
protected function registerRoutes()
6364
{
6465
Route::prefix(config('websockets.path'))->group(function() {
65-
Route::middleware(Authorize::class)->group(function() {
66+
Route::middleware(AuthorizeDashboard::class)->group(function() {
6667
Route::get('/', ShowDashboard::class);
6768
Route::get('/api/{appId}/statistics', [DashboardApiController::class, 'getStatistics']);
6869
Route::post('auth', AuthenticateDashboard::class);
6970
Route::post('event', SendMessage::class);
7071
});
7172

72-
Route::post('statistics', [WebSocketStatisticsEntriesController::class, 'store']);
73+
Route::middleware(AuthorizeStatistics::class)->group(function() {
74+
Route::post('statistics', [WebSocketStatisticsEntriesController::class, 'store']);
75+
});
7376
});
7477

7578
return $this;

tests/Statistics/Controllers/WebSocketsStatisticsControllerTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ public function it_can_store_statistics()
1313
{
1414
$this->post(
1515
action([WebSocketStatisticsEntriesController::class, 'store']),
16-
$this->payload()
16+
array_merge($this->payload(), [
17+
'secret' => config('websockets.apps.0.secret'),
18+
])
1719
);
1820

1921
$entries = WebSocketsStatisticsEntry::get();

0 commit comments

Comments
 (0)