Commit c5ed21cc7ea31f7e62d74c479649797ec9b6d2eb
1 parent
ae89192a
registration
Showing
1 changed file
with
4 additions
and
49 deletions
Show diff stats
app/library/App/Controllers/UserController.php
| ... | ... | @@ -36,61 +36,16 @@ class UserController extends CrudResourceController |
| 36 | 36 | |
| 37 | 37 | public function register() { |
| 38 | 38 | |
| 39 | - $data = $this->getPostedData(); | |
| 39 | + $this->create(); | |
| 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; | |
| 86 | 41 | } |
| 87 | 42 | |
| 88 | 43 | public function whitelist() |
| 89 | 44 | { |
| 90 | 45 | return [ |
| 91 | - 'firstName', | |
| 92 | - 'lastName', | |
| 93 | - 'password' | |
| 46 | + 'username', | |
| 47 | + 'password', | |
| 48 | + 'email' | |
| 94 | 49 | ]; |
| 95 | 50 | } |
| 96 | 51 | } | ... | ... |