guillermo- delete-user [skip ci]
This commit is contained in:
parent
5907cbda00
commit
f3c1882a13
|
@ -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();
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
use Respect\Validation\Validator as DataValidator;
|
||||
DataValidator::with('CustomValidations', true);
|
||||
|
||||
class DeleteUserController extends Controller {
|
||||
const PATH = '/delete';
|
||||
|
||||
public function validations() {
|
||||
return [
|
||||
'permission' => '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();
|
||||
}
|
||||
}
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue