Skip to content

Commit

Permalink
Add Pusher auth endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
phanan committed Aug 25, 2017
1 parent bf1885f commit 7780036
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

use Illuminate\Broadcasting\Broadcasters\PusherBroadcaster;
use Illuminate\Http\Request;

Route::group(['namespace' => 'API'], function () {
Route::post('me', 'AuthController@login');
Route::delete('me', 'AuthController@logout');
Expand All @@ -9,6 +12,19 @@
// Just acting as a ping service.
});

Route::post('broadcasting/auth', function (Request $request) {
$pusher = new Pusher(
config('broadcasting.connections.pusher.key'),
config('broadcasting.connections.pusher.secret'),
config('broadcasting.connections.pusher.app_id'),
[
'cluster' => config('broadcasting.connections.pusher.options.cluster'),
'encrypted' => true,
]
);
return $pusher->socket_auth($request->channel_name, $request->socket_id);
});

Route::get('data', 'DataController@index');

Route::post('settings', 'SettingController@store');
Expand Down

0 comments on commit 7780036

Please sign in to comment.