Skip to content

Commit

Permalink
inject prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Nov 15, 2019
1 parent b204042 commit d77ce36
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Illuminate/Broadcasting/BroadcastManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ protected function createPusherDriver(array $config)
protected function createRedisDriver(array $config)
{
return new RedisBroadcaster(
$this->app->make('redis'), $config['connection'] ?? null
$this->app->make('redis'), $config['connection'] ?? null,
$this->app['config']->get('database.redis.options.prefix', '')
);
}

Expand Down
16 changes: 13 additions & 3 deletions src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,25 @@ class RedisBroadcaster extends Broadcaster
*/
protected $connection;

/**
* The Redis key prefix.
*
* @var string
*/
protected $prefix;

/**
* Create a new broadcaster instance.
*
* @param \Illuminate\Contracts\Redis\Factory $redis
* @param string|null $connection
* @param string $prefix
* @return void
*/
public function __construct(Redis $redis, $connection = null)
public function __construct(Redis $redis, $connection = null, $prefix = '')
{
$this->redis = $redis;
$this->prefix = $prefix;
$this->connection = $connection;
}

Expand All @@ -47,8 +56,9 @@ public function __construct(Redis $redis, $connection = null)
*/
public function auth($request)
{
$channelName = str_replace(config('database.redis.options.prefix', ''), '', $request->channel_name);
$channelName = $this->normalizeChannelName($channelName);
$channelName = $this->normalizeChannelName(
str_replace($this->prefix, '', $request->channel_name)
);

if ($this->isGuardedChannel($request->channel_name) &&
! $this->retrieveUser($request, $channelName)) {
Expand Down

0 comments on commit d77ce36

Please sign in to comment.