2016-09-09 05:38:58 +02:00
|
|
|
<?php
|
|
|
|
use Respect\Validation\Validator as DataValidator;
|
|
|
|
DataValidator::with('CustomValidations', true);
|
|
|
|
|
2017-04-16 07:35:04 +02:00
|
|
|
/**
|
2017-04-21 08:09:24 +02:00
|
|
|
* @api {post} /user/get Retrieve the information of yourself.
|
2017-04-16 07:35:04 +02:00
|
|
|
*
|
2017-04-21 08:09:24 +02:00
|
|
|
* @apiName Get
|
2017-04-16 07:35:04 +02:00
|
|
|
*
|
|
|
|
* @apiGroup User
|
|
|
|
*
|
2017-04-21 08:09:24 +02:00
|
|
|
* @apiDescription This path retrieve the information of a user.
|
2017-04-16 07:35:04 +02:00
|
|
|
*
|
|
|
|
* @apiPermission User
|
|
|
|
*
|
2017-04-21 08:09:24 +02:00
|
|
|
* @apiUse NO_PERMISSION
|
|
|
|
* @apiUse INVALID_CREDENTIALS
|
2017-04-16 07:35:04 +02:00
|
|
|
*
|
|
|
|
* @apiSuccess {Object} data
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-09-09 05:38:58 +02:00
|
|
|
class GetUserController extends Controller {
|
|
|
|
const PATH = '/get';
|
2017-02-08 19:09:15 +01:00
|
|
|
const METHOD = 'POST';
|
2016-09-09 05:38:58 +02:00
|
|
|
|
|
|
|
public function validations() {
|
|
|
|
return [
|
|
|
|
'permission' => 'user',
|
|
|
|
'requestData' => []
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handler() {
|
2016-09-25 06:16:10 +02:00
|
|
|
if (Controller::isStaffLogged()) {
|
|
|
|
Response::respondError(ERRORS::INVALID_CREDENTIALS);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-09 05:38:58 +02:00
|
|
|
$user = Controller::getLoggedUser();
|
|
|
|
$parsedTicketList = [];
|
|
|
|
$ticketList = $user->sharedTicketList;
|
|
|
|
|
|
|
|
foreach($ticketList as $ticket) {
|
|
|
|
$parsedTicketList[] = $ticket->toArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
Response::respondSuccess([
|
|
|
|
'name' => $user->name,
|
|
|
|
'email' => $user->email,
|
2017-01-10 17:19:36 +01:00
|
|
|
'verified' => !$user->verificationToken,
|
2016-09-09 05:38:58 +02:00
|
|
|
'tickets' => $parsedTicketList
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|