| Conditions | 4 |
| Paths | 8 |
| Total Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | public function handle(SpikeInterface $message) |
||
| 25 | { |
||
| 26 | $auth = $message->getBody(); |
||
| 27 | try{ |
||
| 28 | $authentication = $this->server->getConfiguration()->getAuthentication(); |
||
| 29 | if (!$authentication |
||
| 30 | || $authentication->verify($auth) |
||
| 31 | ) { |
||
| 32 | $client = new Client($message->getBody(), $this->connection); |
||
| 33 | $this->server->getClients()->add($client); |
||
| 34 | $response = new Spike('auth_response', $client->toArray(), [ |
||
| 35 | 'code' => 200, |
||
| 36 | ]); |
||
| 37 | } else { |
||
| 38 | $response = new Spike('auth_response', $auth, [ |
||
| 39 | 'code' => 403, |
||
| 40 | ]); |
||
| 41 | } |
||
| 42 | } catch (InvalidArgumentException $exception) { |
||
| 43 | $response = new Spike('auth_response', $auth, [ |
||
| 44 | 'code' => 403, |
||
| 45 | 'message' => $exception->getMessage(), |
||
| 46 | ]); |
||
| 47 | } |
||
| 48 | $this->connection->write($response); |
||
| 49 | } |
||
| 50 | } |