Add updateUserInfo API endpoint

This commit is contained in:
BitHeaven 2024-08-09 21:56:25 +05:00
parent 44cb07fe0b
commit e38bef492e
1 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,34 @@
<?php
if($_SERVER['REQUEST_METHOD'] == 'UPDATE') {
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,
'message' => 'Только UPDATE метод',
];
}