diff --git a/app/library/App/Controllers/UserController.php b/app/library/App/Controllers/UserController.php index 5b31e1b..af61b60 100755 --- a/app/library/App/Controllers/UserController.php +++ b/app/library/App/Controllers/UserController.php @@ -44,7 +44,44 @@ class UserController extends CrudResourceController public function registration() { - return $this->createResponse($this->create()); + $this->beforeHandle(); + $this->beforeHandleWrite(); + $this->beforeHandleCreate(); + + $data = $this->getPostedData(); + + if (!$data || count($data) == 0) { + return $this->onNoDataProvided(); + } + + if (!$this->postDataValid($data, false)) { + return $this->onDataInvalid($data); + } + + if (!$this->saveAllowed($data) || !$this->createAllowed($data)) { + return $this->onNotAllowed(); + } + + $data = $this->transformPostData($data); + + $item = $this->createModelInstance(); + + $newItem = $this->createItem($item, $data); + + if (!$newItem) { + return $this->onCreateFailed($item, $data); + } + + $primaryKey = $this->getModelPrimaryKey(); + $responseData = $this->getFindData($newItem->$primaryKey); + + $response = $this->getCreateResponse($responseData, $data); + + $this->afterHandleCreate($newItem, $data, $response); + $this->afterHandleWrite(); + $this->afterHandle(); + + return $response; } -- libgit2 0.21.4