/** * @param Identity $identity * @return mixed * @throws \Exception */ public function auth(Identity $identity) { if (StrUtil::startsWith($identity->channel, ['private-', 'presence-']) && empty($identity->identifier)) { throw new \Exception('Unauthorized', 403); } return parent::verifyThatIdentityCanAccessChannel($identity, str_replace(['private-', 'presence-'], '', $identity->channel)); }
/** * @param Identity $identity * @param $response * @return string signature */ public function validAuthenticationResponse(Identity $identity, $response) { if (StrUtil::startsWith($identity->channel, 'private')) { return $this->pusher->socket_auth($identity->channel, $identity->socketId); } else { return $this->pusher->presence_auth($identity->channel, $identity->socketId, $identity->identifier, $response); } }
public function testStringStartsNotWithMultiple() { $result = StrUtil::startsWith('foo-bar', ['bar', 'bar']); $this->assertFalse($result); }