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