mirror of
https://github.com/grocy/grocy.git
synced 2025-08-13 09:17:26 +00:00
Better API response when request body is not valid JSON (references #126)
This commit is contained in:
@@ -32,6 +32,11 @@ class UsersApiController extends BaseApiController
|
||||
|
||||
try
|
||||
{
|
||||
if ($requestBody === null)
|
||||
{
|
||||
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
|
||||
}
|
||||
|
||||
$this->UsersService->CreateUser($requestBody['username'], $requestBody['first_name'], $requestBody['last_name'], $requestBody['password']);
|
||||
return $this->ApiResponse(array('success' => true));
|
||||
}
|
||||
|
Reference in New Issue
Block a user