1

If I set my channel like this, I get console error 403.
note:: if ($user->status) isn't reg.

Broadcast::channel('using', function ($user) {
    if($user->status=='reg'){
       return $user->id;
    }
});

If I set my channel like this, everything is okay.

Broadcast::channel('using', function ($user) {
    if($user->status=='reg'){
        return $user->id;
    }else{
        return 'invalid';
    }
});

But I need to set my channel when $user->status isn't reg, I don't want to give any return.
Problem is if I don't give any return, I get console error 403.
Sorry for my english skill

1 Answers1

0

The data returned by the authorization callback will be made available to the presence channel event listeners in your JavaScript application. If the user is not authorized to join the presence channel, you should return false or null:

https://laravel.com/docs/8.x/broadcasting#authorizing-presence-channels

For $user->status isn't reg, you do not need to return data payload. You only return false or null.

Thân LƯƠNG Đình
  • 3,082
  • 2
  • 11
  • 21
  • If I return false or null, I get console error 403 from backend. Because user is already login but status is not get a permission. So I don't want to give any retrun. Now I used `$user->status` isn't 'reg', I call `die()`. – MraukOoDeveloper Dec 07 '20 at 04:54