Guillermo - path-delete-all-users [skip ci]

This commit is contained in:
AntonyAntonio 2017-01-12 17:06:41 -03:00
parent ae27ee390e
commit 1d514dda58
2 changed files with 34 additions and 0 deletions

View File

@ -11,6 +11,7 @@ require_once 'system/edit-mail-template.php';
require_once 'system/recover-mail-template.php';
require_once 'system/disable-registration.php';
require_once 'system/enable-registration.php';
require_once 'system/delete-all-users.php';
$systemControllerGroup = new ControllerGroup();
$systemControllerGroup->setGroupPath('/system');
@ -27,5 +28,6 @@ $systemControllerGroup->addController(new EditMailTemplateController);
$systemControllerGroup->addController(new RecoverMailTemplateController);
$systemControllerGroup->addController(new DisableRegistrationController);
$systemControllerGroup->addController(new EnableRegistrationController);
$systemControllerGroup->addController(new DeleteAllUsersController);
$systemControllerGroup->finalize();

View File

@ -0,0 +1,32 @@
<?php
use RedBeanPHP\Facade as RedBean;
class DeleteAllUsersController extends Controller {
const PATH = '/delete-all-users';
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;
}
Redbean::exec('SET FOREIGN_KEY_CHECKS = 0;');
RedBean::wipe(SessionCookie::TABLE);
RedBean::wipe(User::TABLE);
RedBean::wipe(Ticket::TABLE);
RedBean::wipe(Ticketevent::TABLE);
RedBean::wipe('ticket_user');
Redbean::exec('SET FOREIGN_KEY_CHECKS = 1;');
Response::respondSuccess();
}
}