From 3754fbeb53922364bcddfd016f934d914247420b Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 16 Feb 2017 17:39:06 +0200 Subject: [PATCH] registration --- app/library/App/Controllers/UserController.php | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/app/library/App/Controllers/UserController.php b/app/library/App/Controllers/UserController.php index 3335e12..f175633 100755 --- a/app/library/App/Controllers/UserController.php +++ b/app/library/App/Controllers/UserController.php @@ -36,7 +36,47 @@ class UserController extends CrudResourceController public function register() { - parent::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); + } + + die(var_dump($newItem)); + + $primaryKey = $this->getModelPrimaryKey(); + $responseData = $this->getFindData($newItem->$primaryKey); + + $response = $this->getCreateResponse($responseData, $data); + + $this->afterHandleCreate($newItem, $data, $response); + $this->afterHandleWrite(); + $this->afterHandle(); + + return $response; + } public function whitelist() -- libgit2 0.21.4