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

35 lines
716 B
PHP
Raw 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'] == '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 метод',
];
}