Пример #1
0
 /**
  * @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));
 }
Пример #2
0
 /**
  * @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);
     }
 }
Пример #3
0
 public function testStringStartsNotWithMultiple()
 {
     $result = StrUtil::startsWith('foo-bar', ['bar', 'bar']);
     $this->assertFalse($result);
 }