Handle user not found properly

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-05-07 19:16:56 +01:00
parent 386b2839e8
commit 8c327e6523

View file

@ -416,13 +416,16 @@ class UsersController extends Controller
$this->authorize('view', User::class); $this->authorize('view', User::class);
$user = User::withCount('assets as assets_count', 'licenses as licenses_count', 'accessories as accessories_count', 'consumables as consumables_count', 'managesUsers as manages_users_count', 'managedLocations as manages_locations_count'); $user = User::withCount('assets as assets_count', 'licenses as licenses_count', 'accessories as accessories_count', 'consumables as consumables_count', 'managesUsers as manages_users_count', 'managedLocations as manages_locations_count');
$user = Company::scopeCompanyables($user)->find($id);
if ($user = Company::scopeCompanyables($user)->find($id)) {
$this->authorize('view', $user); $this->authorize('view', $user);
return (new UsersTransformer)->transformUser($user); return (new UsersTransformer)->transformUser($user);
} }
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.user_not_found', compact('id'))));
}
/** /**
* Update the specified resource in storage. * Update the specified resource in storage.