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

28 lines
543 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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 метод',
];
}