mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 21:54:14 -08:00
Handle user not found properly
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
386b2839e8
commit
8c327e6523
|
@ -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.
|
||||||
|
|
Loading…
Reference in a new issue