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