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

35 lines
714 B
PHP
Raw Permalink Normal View History

2024-08-10 00:56:25 +08:00
<?php
2024-08-10 00:57:39 +08:00
if($_SERVER['REQUEST_METHOD'] == 'PATCH') {
2024-08-10 00:56:25 +08:00
if(!isset($_REQUEST['token'])) {
$data = [
'error' => true,
'message' => 'Не передано поле token',
];
}
elseif(!isset($_REQUEST['newInfo'])) {
$data = [
'error' => true,
'message' => 'Не передано поле newInfo',
];
}
elseif(!User::updateInfo($_REQUEST['token'], $_REQUEST['newInfo'])) {
$data = [
'error' => true,
'message' => 'Невалидный токен',
];
}
else {
$data = [
'error' => false,
'message' => 'Информация обновлена',
];
}
}
else {
$data = [
'error' => true,
2024-08-10 00:57:39 +08:00
'message' => 'Только PATCH метод',
2024-08-10 00:56:25 +08:00
];
}