Fix getUser endpoint

This commit is contained in:
BitHeaven 2024-08-09 21:53:15 +05:00
parent 0bcd0f8483
commit 44cb07fe0b
1 changed files with 21 additions and 13 deletions

View File

@ -1,19 +1,27 @@
<?php
if(!isset($_GET['login'])) {
$data = [
'error' => true,
'message' => 'Не передано поле login',
];
}
elseif(!$user = User::get($_GET['login'])) {
$data = [
'error' => true,
'message' => 'Пользователь не существует',
];
if($_SERVER['REQUEST_METHOD'] == 'GET') {
if(!isset($_REQUEST['login'])) {
$data = [
'error' => true,
'message' => 'Не передано поле login',
];
}
elseif(!$user = User::get($_REQUEST['login'])) {
$data = [
'error' => true,
'message' => 'Пользователь не существует',
];
}
else {
$data = [
'error' => false,
'data' => $user,
];
}
}
else {
$data = [
'error' => false,
'data' => $user,
'error' => true,
'message' => 'Только метод GET',
];
}