From 95d1b70cb2a970cc6d1f834ed43f50c82da2c61c Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 16 Feb 2017 17:08:41 +0200 Subject: [PATCH] registration --- app/library/App/Controllers/UserController.php | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/app/library/App/Controllers/UserController.php b/app/library/App/Controllers/UserController.php index ee73588..f11a724 100755 --- a/app/library/App/Controllers/UserController.php +++ b/app/library/App/Controllers/UserController.php @@ -34,7 +34,39 @@ class UserController extends CrudResourceController } public function register() { - parent::create(); + + $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); + + die($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); + + return $response; } public function whitelist() -- libgit2 0.21.4