diff --git a/server/controllers/system.php b/server/controllers/system.php index 1d8fa889..2f2c65c6 100644 --- a/server/controllers/system.php +++ b/server/controllers/system.php @@ -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(); \ No newline at end of file diff --git a/server/controllers/system/delete-all-users.php b/server/controllers/system/delete-all-users.php new file mode 100644 index 00000000..63749e59 --- /dev/null +++ b/server/controllers/system/delete-all-users.php @@ -0,0 +1,32 @@ + '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(); + } +} \ No newline at end of file