This commit is contained in:
Marcel Pociot 2018-12-04 10:25:34 +01:00
parent 09396cd92c
commit c050fe87e2
3 changed files with 10 additions and 5 deletions

View File

@ -36,7 +36,7 @@ class App
public static function findBySecret(string $appSecret): ?App
{
return app(AppProvider::class)->findByKey($appSecret);
return app(AppProvider::class)->findBySecret($appSecret);
}
public function __construct($appId, string $appKey, string $appSecret)

View File

@ -6,7 +6,8 @@ use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\AuthenticateDashboar
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\DashboardApiController;
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\SendMessage;
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\ShowDashboard;
use BeyondCode\LaravelWebSockets\Dashboard\Http\Middleware\Authorize;
use BeyondCode\LaravelWebSockets\Dashboard\Http\Middleware\Authorize as AuthorizeDashboard;
use BeyondCode\LaravelWebSockets\Statistics\Http\Middleware\Authorize as AuthorizeStatistics;
use BeyondCode\LaravelWebSockets\Server\Router;
use BeyondCode\LaravelWebSockets\Statistics\Http\Controllers\WebSocketStatisticsEntriesController;
use BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger;
@ -62,15 +63,17 @@ class WebSocketsServiceProvider extends ServiceProvider
protected function registerRoutes()
{
Route::prefix(config('websockets.path'))->group(function() {
Route::middleware(Authorize::class)->group(function() {
Route::middleware(AuthorizeDashboard::class)->group(function() {
Route::get('/', ShowDashboard::class);
Route::get('/api/{appId}/statistics', [DashboardApiController::class, 'getStatistics']);
Route::post('auth', AuthenticateDashboard::class);
Route::post('event', SendMessage::class);
});
Route::middleware(AuthorizeStatistics::class)->group(function() {
Route::post('statistics', [WebSocketStatisticsEntriesController::class, 'store']);
});
});
return $this;
}

View File

@ -13,7 +13,9 @@ class WebSocketsStatisticsControllerTest extends TestCase
{
$this->post(
action([WebSocketStatisticsEntriesController::class, 'store']),
$this->payload()
array_merge($this->payload(), [
'secret' => config('websockets.apps.0.secret'),
])
);
$entries = WebSocketsStatisticsEntry::get();