Commit 3754fbeb53922364bcddfd016f934d914247420b

Authored by Alex Savenko
1 parent 30944c2d

registration

Showing 1 changed file with 41 additions and 1 deletions   Show diff stats
app/library/App/Controllers/UserController.php
... ... @@ -36,7 +36,47 @@ class UserController extends CrudResourceController
36 36  
37 37 public function register() {
38 38  
39   - parent::create();
  39 + $this->beforeHandle();
  40 + $this->beforeHandleWrite();
  41 + $this->beforeHandleCreate();
  42 +
  43 + $data = $this->getPostedData();
  44 +
  45 + if (!$data || count($data) == 0) {
  46 + return $this->onNoDataProvided();
  47 + }
  48 +
  49 + if (!$this->postDataValid($data, false)) {
  50 + return $this->onDataInvalid($data);
  51 + }
  52 +
  53 + if (!$this->saveAllowed($data) || !$this->createAllowed($data)) {
  54 + return $this->onNotAllowed();
  55 + }
  56 +
  57 + $data = $this->transformPostData($data);
  58 +
  59 + $item = $this->createModelInstance();
  60 +
  61 + $newItem = $this->createItem($item, $data);
  62 +
  63 + if (!$newItem) {
  64 + return $this->onCreateFailed($item, $data);
  65 + }
  66 +
  67 + die(var_dump($newItem));
  68 +
  69 + $primaryKey = $this->getModelPrimaryKey();
  70 + $responseData = $this->getFindData($newItem->$primaryKey);
  71 +
  72 + $response = $this->getCreateResponse($responseData, $data);
  73 +
  74 + $this->afterHandleCreate($newItem, $data, $response);
  75 + $this->afterHandleWrite();
  76 + $this->afterHandle();
  77 +
  78 + return $response;
  79 +
40 80 }
41 81  
42 82 public function whitelist()
... ...