Example #1
0
 public function logInBackend($username = '******', $password = '******')
 {
     if ($this->um->isAuthenticated() === false) {
         $this->client->request('GET', '/' . $this->api['backend'] . '/user/login/?username='******'&password='******'CONTENT_TYPE' => 'application/json']);
         $response = $this->client->getResponse();
         $content = $response->getContent();
         $result = json_decode($content, true);
         if ($result['status'] !== true) {
             throw new \LogicException('Authentication failed.');
         }
     }
     return $this->um->isAuthenticated();
 }
 public function logInFrontend($username = '******', $password = '******')
 {
     if ($this->um->isAuthenticated() === false) {
         $data = ['username' => $username, 'password' => $password];
         $this->client->request('POST', '/' . $this->api['frontend'] . '/user/login/', [], [], ['CONTENT_TYPE' => 'application/json'], json_encode($data));
         $response = $this->client->getResponse();
         $content = $response->getContent();
         $result = json_decode($content, true);
         if ($result['status'] !== true) {
             throw new \LogicException('Authentication failed.');
         }
     }
     return $this->um->isAuthenticated();
 }