Add deleteUser API endpoint

This commit is contained in:
BitHeaven 2024-08-09 21:51:30 +05:00
parent 755784a870
commit 0bcd0f8483
1 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,27 @@
<?php
if($_SERVER['REQUEST_METHOD'] == 'DELETE') {
if(!isset($_REQUEST['token'])) {
$data = [
'error' => true,
'message' => 'Не передано поле token',
];
}
elseif(!User::delete($_REQUEST['token'])) {
$data = [
'error' => true,
'message' => 'Невалидный токен',
];
}
else {
$data = [
'error' => false,
'message' => 'Пользователь удален',
];
}
}
else {
$data = [
'error' => true,
'message' => 'Только DELETE метод',
];
}