Merged in OS-149-delete-all-users (pull request #120)
Guillermo - path-delete-all-users
This commit is contained in:
commit
a34429d32a
|
@ -15,6 +15,7 @@ require_once 'system/enable-registration.php';
|
|||
require_once 'system/add-api-key.php';
|
||||
require_once 'system/delete-api-key.php';
|
||||
require_once 'system/get-all-keys.php';
|
||||
require_once 'system/delete-all-users.php';
|
||||
|
||||
$systemControllerGroup = new ControllerGroup();
|
||||
$systemControllerGroup->setGroupPath('/system');
|
||||
|
@ -35,5 +36,6 @@ $systemControllerGroup->addController(new GetStatsController);
|
|||
$systemControllerGroup->addController(new AddAPIKeyController);
|
||||
$systemControllerGroup->addController(new DeleteAPIKeyController);
|
||||
$systemControllerGroup->addController(new GetAllKeyController);
|
||||
$systemControllerGroup->addController(new DeleteAllUsersController);
|
||||
|
||||
$systemControllerGroup->finalize();
|
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue