Better handle API calls to nonexistent users

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2022-06-03 16:55:23 -07:00
parent 7ca617f077
commit 07b1062fb2

View file

@ -519,10 +519,14 @@ class UsersController extends Controller
{
$this->authorize('view', User::class);
$this->authorize('view', License::class);
$user = User::where('id', $id)->withTrashed()->first();
$licenses = $user->licenses()->get();
if ($user = User::where('id', $id)->withTrashed()->first()) {
$licenses = $user->licenses()->get();
return (new LicensesTransformer())->transformLicenses($licenses, $licenses->count());
}
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.user_not_found', compact('id'))));
return (new LicensesTransformer())->transformLicenses($licenses, $licenses->count());
}
/**