pusherer icon indicating copy to clipboard operation
pusherer copied to clipboard

Auth and private channel

Open 1e4 opened this issue 9 years ago • 3 comments

Is there anyway to auth a user with laravels Auth::check() and only send data to private channels?

1e4 avatar Aug 28 '14 11:08 1e4

I am also trying to do the same. Any ideas??

gurpreet2013 avatar Jan 19 '15 21:01 gurpreet2013

Nope no answer yet.

1e4 avatar Jan 24 '15 13:01 1e4

i don't know if you solved that problem, but the soluction is:

1 - Create PusherController


    public function auth()
    {
        // make your logic to allow autentication
        if (Input::has('channel_name') && Input::has('socket_id')) {
            $socket = Pusherer::socket_auth(Input::get('channel_name'), Input::get('socket_id'));
            return Response::make($socket);
        }

        return Response::make('Forbidden', 403);
    }

2 - routes.php, you need create /pusher/auth

Route::post('/pusher/auth',  array('as' => 'api.pusher', 'uses' => 'PusherController@auth'));

Done. Now whenever you subscribe to a channel with private prefix, you will consult this route to authenticate.

gpedro avatar Oct 28 '15 19:10 gpedro