1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-25 05:42:23 +00:00

Fix user deletion

This commit is contained in:
Yohann D'ANELLO 2020-04-13 03:57:34 +02:00
parent 50aec3c105
commit a322ce4dfb

View File

@ -5,6 +5,9 @@ if (!isset($_SESSION["role"]))
$id = $_GET["id"];
$user = User::fromId($id);
if ($user == null)
require_once "server_files/404.php";
$team = Team::fromId($user->getTeamId());
if ($_SESSION["role"] != Role::ADMIN) {
@ -70,9 +73,6 @@ if (isset($_POST["view_as"]) && $_SESSION["role"] == Role::ADMIN) {
}
if (isset($_POST["delete_account"]) && $team == null && $_SESSION["role"] == Role::ADMIN) {
/** @var Document $document */
foreach ($user->getAllDocuments($team->getTournamentId()) as $document)
unlink($LOCAL_PATH . "/files/" . $document->getFileId());
$DB->prepare("DELETE FROM `documents` WHERE `user` = ?;")->execute([$user->getId()]);
$DB->prepare("DELETE FROM `organizers` WHERE `organizer` = ?;")->execute([$user->getId()]);
$DB->prepare("DELETE FROM `users` WHERE `id` = ?;")->execute([$user->getId()]);