From f3c1882a13dde7a11de430894bdda22c21f798cf Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 30 Nov 2016 17:30:00 -0300 Subject: [PATCH] guillermo- delete-user [skip ci] --- server/controllers/user.php | 7 ++++--- server/controllers/user/delete.php | 27 +++++++++++++++++++++++++++ server/controllers/user/get-user.php | 2 +- 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 server/controllers/user/delete.php diff --git a/server/controllers/user.php b/server/controllers/user.php index e2fe6442..0080f8e8 100644 --- a/server/controllers/user.php +++ b/server/controllers/user.php @@ -9,7 +9,8 @@ include 'user/edit-password.php'; include 'user/edit-email.php'; include 'user/get.php'; include 'user/get-users.php'; -include 'user/get-user'; +include 'user/get-user.php'; +include 'user/delete.php'; $userControllers = new ControllerGroup(); $userControllers->setGroupPath('/user'); @@ -24,6 +25,6 @@ $userControllers->addController(new EditPassword); $userControllers->addController(new EditEmail); $userControllers->addController(new GetUserController); $userControllers->addController(new GetUsersController); -$userControllers->addController(new GetUserController); - +$userControllers->addController(new GetUserByIdController); +$userControllers->addController(new DeleteUserController); $userControllers->finalize(); diff --git a/server/controllers/user/delete.php b/server/controllers/user/delete.php new file mode 100644 index 00000000..6240218a --- /dev/null +++ b/server/controllers/user/delete.php @@ -0,0 +1,27 @@ + 'staff_1', + 'requestData' => [ + 'userId' => [ + 'validation' => DataValidator::dataStoreId('user'), + 'error' => ERRORS::INVALID_USER + ] + ] + ]; + } + + public function handler() { + $userId = Controller::request('userId'); + $user = User::getDataStore($userId); + + $user->delete(); + Response::respondSuccess(); + } +} \ No newline at end of file diff --git a/server/controllers/user/get-user.php b/server/controllers/user/get-user.php index 76d83c4d..92636ac0 100644 --- a/server/controllers/user/get-user.php +++ b/server/controllers/user/get-user.php @@ -2,7 +2,7 @@ use Respect\Validation\Validator as DataValidator; DataValidator::with('CustomValidations', true); -class GetUserController extends Controller { +class GetUserByIdController extends Controller { const PATH = '/get-user'; public function validations() {