guillermo- get-user [skip ci]
This commit is contained in:
parent
8ab6240385
commit
5907cbda00
|
@ -9,6 +9,7 @@ include 'user/edit-password.php';
|
|||
include 'user/edit-email.php';
|
||||
include 'user/get.php';
|
||||
include 'user/get-users.php';
|
||||
include 'user/get-user';
|
||||
|
||||
$userControllers = new ControllerGroup();
|
||||
$userControllers->setGroupPath('/user');
|
||||
|
@ -23,5 +24,6 @@ $userControllers->addController(new EditPassword);
|
|||
$userControllers->addController(new EditEmail);
|
||||
$userControllers->addController(new GetUserController);
|
||||
$userControllers->addController(new GetUsersController);
|
||||
$userControllers->addController(new GetUserController);
|
||||
|
||||
$userControllers->finalize();
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
use Respect\Validation\Validator as DataValidator;
|
||||
DataValidator::with('CustomValidations', true);
|
||||
|
||||
class GetUserController extends Controller {
|
||||
const PATH = '/get-user';
|
||||
|
||||
public function validations() {
|
||||
return [
|
||||
'permission' => 'staff_2',
|
||||
'requestData' => [
|
||||
'userId' => [
|
||||
'validation' => DataValidator::dataStoreId('user'),
|
||||
'error' => ERRORS::INVALID_USER
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function handler() {
|
||||
$userId = Controller::request('userId');
|
||||
$user = User::getDataStore($userId);
|
||||
|
||||
Response::respondSuccess([
|
||||
'name' => $user->name,
|
||||
'email' => $user->email,
|
||||
'signupDate' => $user->signupDate,
|
||||
'tickets' => $user->sharedTicketList->toArray()
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -24,4 +24,5 @@ class ERRORS {
|
|||
const INVALID_TOPIC = 'INVALID_TOPIC';
|
||||
const INVALID_SEARCH = 'INVALID_SEARCH';
|
||||
const INVALID_ORDER = 'INVALID_ORDER';
|
||||
const INVALID_USER = 'INVALID_USER';
|
||||
}
|
||||
|
|
|
@ -17,8 +17,7 @@ class User extends DataStore {
|
|||
'name',
|
||||
'signupDate',
|
||||
'tickets',
|
||||
'sharedTicketList',
|
||||
'verificationToken'
|
||||
'sharedTicketList'
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue