opensupports/server/controllers/system/delete-all-users.php

54 lines
1.3 KiB
PHP
Raw Normal View History

<?php
use RedBeanPHP\Facade as RedBean;
2017-04-18 02:09:16 +02:00
/**
* @api {post} /system/delete-all-users Delete all users
2018-09-20 22:19:47 +02:00
* @apiVersion 4.3.0
2017-04-18 02:09:16 +02:00
*
* @apiName Delete all users
*
* @apiGroup System
2017-04-18 02:09:16 +02:00
*
* @apiDescription This path deletes all users in database.
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
*
* @apiSuccess {Object} data Empty object
2017-04-18 02:09:16 +02:00
*
*/
class DeleteAllUsersController extends Controller {
const PATH = '/delete-all-users';
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;
}
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();
}
}