test-php-rest-api-user/engine/core/api/v1/deleteUser.php

28 lines
543 B
PHP
Raw Normal View History

2024-08-10 00:51:30 +08:00
<?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 метод',
];
}