/**
  * @return array|bool
  * @throws \yii\db\Exception
  */
 public function signUp()
 {
     if (!$this->validate()) {
         return false;
     }
     $dbTransaction = Yii::$app->db->beginTransaction();
     try {
         $user = new User();
         $user->email = $this->email;
         $user->setPassword($this->password);
         if (!$user->save()) {
             throw new ErrorException('Could not create User');
         }
         $this->_user = $user;
         $client = new Client();
         $client->setUser($user);
         $client->generateToken();
         if (!$client->save()) {
             throw new ErrorException('Could not create Client');
         }
     } catch (ErrorException $e) {
         $dbTransaction->rollBack();
         return false;
     }
     $dbTransaction->commit();
     return ['user' => $user, 'client' => $client];
 }
 public function auth()
 {
     if (!$this->validate()) {
         return false;
     }
     $client = new Client();
     $client->setUser($this->_user);
     $client->generateToken();
     if (!$client->save()) {
         $this->addError('password', 'Could not create Client');
         return false;
     }
     return ['user' => $this->_user, 'client' => $client];
 }