Commit 045b468bffc122e1d42c1e8ac15f5fa9d320e13c
1 parent
284ad890
user registration
Showing
2 changed files
with
2 additions
and
40 deletions
Show diff stats
app/library/App/Controllers/UserController.php
| @@ -46,45 +46,7 @@ class UserController extends CrudResourceController | @@ -46,45 +46,7 @@ class UserController extends CrudResourceController | ||
| 46 | 46 | ||
| 47 | public function registration() { | 47 | public function registration() { |
| 48 | 48 | ||
| 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 | - $newItem = $this->createItem($item, $data); | ||
| 72 | - | ||
| 73 | - if (!$newItem) { | ||
| 74 | - return $this->onCreateFailed($item, $data); | ||
| 75 | - } | ||
| 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; | 49 | + return $this->create(); |
| 88 | 50 | ||
| 89 | } | 51 | } |
| 90 | 52 |
app/library/App/Resources/UserResource.php
| @@ -26,7 +26,7 @@ class UserResource extends ApiResource { | @@ -26,7 +26,7 @@ class UserResource extends ApiResource { | ||
| 26 | ->allow(AclRoles::USER) | 26 | ->allow(AclRoles::USER) |
| 27 | ->description('Returns all registered users') | 27 | ->description('Returns all registered users') |
| 28 | ) | 28 | ) |
| 29 | - ->endpoint(ApiEndpoint::get('/me', 'me') | 29 | + ->endpoint(ApiEndpoint::get('/me', 'me') |
| 30 | ->allow(AclRoles::USER) | 30 | ->allow(AclRoles::USER) |
| 31 | ->description('Returns the currently logged in user') | 31 | ->description('Returns the currently logged in user') |
| 32 | ) | 32 | ) |