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