diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index c2c2c642a..b4d9beb21 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -133,7 +133,8 @@ $utopia->post('/v1/account') ->setParam('resource', 'users/'.$user->getId()) ; - $response->dynamic($user); + $response->json($user->getArrayCopy()); + //$response->dynamic($user); } ); diff --git a/app/init.php b/app/init.php index 69795f56c..c6f531e08 100644 --- a/app/init.php +++ b/app/init.php @@ -22,7 +22,7 @@ use Appwrite\Database\Document; use Appwrite\Database\Validator\Authorization; use Appwrite\Database\Adapter\MySQL as MySQLAdapter; use Appwrite\Database\Adapter\Redis as RedisAdapter; -use Appwrite\Response\Response; +use Appwrite\Utopia\Response; use PHPMailer\PHPMailer\PHPMailer; const APP_NAME = 'Appwrite'; diff --git a/src/Appwrite/Response/Result/Sessions.php b/src/Appwrite/Response/Result/Sessions.php deleted file mode 100644 index b778655a2..000000000 --- a/src/Appwrite/Response/Result/Sessions.php +++ /dev/null @@ -1,37 +0,0 @@ -addRule('$id', 'string', 'Session ID.', '5e5ea5c16897e') - ->addRule('expire', 'integer', 'Session expiration date in UNIX format.', 1583261121) - ; - } - - /** - * Get Name - * - * @return string - */ - public function getName():string - { - return 'Session'; - } - - /** - * Get Collection - * - * @return string - */ - public function getCollection():string - { - return Database::SYSTEM_COLLECTION_TOKENS; - } -} \ No newline at end of file diff --git a/src/Appwrite/Response/Response.php b/src/Appwrite/Utopia/Response.php similarity index 89% rename from src/Appwrite/Response/Response.php rename to src/Appwrite/Utopia/Response.php index 4abb0c36c..cd25802cc 100644 --- a/src/Appwrite/Response/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -1,10 +1,11 @@ setResult(new User) + ->setResult(new User()) ; } @@ -47,7 +48,7 @@ class Response extends UtopiaResponse public function getResult(string $key): Result { if(!isset($this->results[$key])) { - throw new Exception('Undefined result'); + throw new Exception('Undefined result: '.$key); } return $this->results[$key]; @@ -66,7 +67,7 @@ class Response extends UtopiaResponse foreach($result->getRules() as $key => $rule) { if(!isset($data[$key])) { - throw new Exception('Missing result key'); + throw new Exception('Missing response key: ' . $key); } $output[$key] = $data[$key]; diff --git a/src/Appwrite/Response/Result.php b/src/Appwrite/Utopia/Response/Result.php similarity index 95% rename from src/Appwrite/Response/Result.php rename to src/Appwrite/Utopia/Response/Result.php index adc1c9f7d..a65f7ae10 100644 --- a/src/Appwrite/Response/Result.php +++ b/src/Appwrite/Utopia/Response/Result.php @@ -1,6 +1,6 @@