opensupports/server/controllers/system/enable-registration.php

51 lines
1.2 KiB
PHP
Raw Normal View History

<?php
use Respect\Validation\Validator as DataValidator;
2017-04-18 02:09:16 +02:00
/**
* @api {post} /system/enable-registration Enable registration
2018-09-20 22:19:47 +02:00
* @apiVersion 4.3.0
2017-04-18 02:09:16 +02:00
*
* @apiName Enable registration
*
* @apiGroup System
2017-04-18 02:09:16 +02:00
*
* @apiDescription This path enables the registration.
2017-04-18 02:09:16 +02:00
*
* @apiPermission staff3
2017-04-18 02:09:16 +02:00
*
2017-04-21 08:09:24 +02:00
* @apiParam {String} password The password of the current staff.
2017-04-18 02:09:16 +02:00
*
2017-04-21 08:09:24 +02:00
* @apiUse NO_PERMISSION
* @apiUse INVALID_PASSWORD
2017-04-18 02:09:16 +02:00
*
2017-04-21 08:09:24 +02:00
* @apiSuccess {Object} data Empty object
2017-04-18 02:09:16 +02:00
*
*/
class EnableRegistrationController extends Controller {
const PATH = '/enable-registration';
const METHOD = 'POST';
public function validations() {
return [
'permission' => 'staff_3',
'requestData' => []
];
}
public function handler() {
$password = Controller::request('password');
if(!Hashing::verifyPassword($password,Controller::getLoggedUser()->password)) {
Response::respondError(ERRORS::INVALID_PASSWORD);
return;
}
$registrationRow = Setting::getSetting('registration');
$registrationRow->value = true;
$registrationRow->store();
Response::respondSuccess();
}
}