2018-09-28 00:46:30 +02:00
|
|
|
<?php
|
|
|
|
use Respect\Validation\Validator as DataValidator;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @api {post} /user/enable Ban email
|
2021-10-19 03:06:20 +02:00
|
|
|
* @apiVersion 4.10.0
|
2018-09-28 00:46:30 +02:00
|
|
|
*
|
|
|
|
* @apiName Enable User
|
|
|
|
*
|
|
|
|
* @apiGroup User
|
|
|
|
*
|
|
|
|
* @apiDescription This path takes an user id and enables it
|
|
|
|
*
|
|
|
|
* @apiPermission staff1
|
|
|
|
*
|
|
|
|
* @apiParam {String} userId Id of the user to enable
|
|
|
|
*
|
|
|
|
* @apiUse NO_PERMISSION
|
|
|
|
* @apiUse INVALID_USER
|
|
|
|
* @apiUse ALREADY_ENABLED
|
|
|
|
*
|
|
|
|
* @apiSuccess {Object} data Empty object
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class EnableUserController extends Controller {
|
|
|
|
const PATH = '/enable';
|
|
|
|
const METHOD = 'POST';
|
|
|
|
|
|
|
|
public function validations() {
|
|
|
|
return [
|
|
|
|
'permission' => 'staff_1',
|
|
|
|
'requestData' => [
|
|
|
|
'userId' => [
|
|
|
|
'validation' => DataValidator::dataStoreId('user'),
|
|
|
|
'error' => ERRORS::INVALID_USER
|
|
|
|
]
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handler() {
|
|
|
|
$user = User::getDataStore(Controller::request('userId'));
|
|
|
|
|
|
|
|
if(!$user->disabled) {
|
2018-11-20 23:41:00 +01:00
|
|
|
throw new RequestException(ERRORS::ALREADY_ENABLED);
|
2018-09-28 00:46:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$user->disabled = 0;
|
|
|
|
$user->store();
|
|
|
|
|
|
|
|
Response::respondSuccess();
|
|
|
|
}
|
|
|
|
}
|