mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Handle user not found properly
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
386b2839e8
commit
8c327e6523
|
@ -416,11 +416,14 @@ class UsersController extends Controller
|
|||
$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 = Company::scopeCompanyables($user)->find($id);
|
||||
|
||||
$this->authorize('view', $user);
|
||||
if ($user = Company::scopeCompanyables($user)->find($id)) {
|
||||
$this->authorize('view', $user);
|
||||
return (new UsersTransformer)->transformUser($user);
|
||||
}
|
||||
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.user_not_found', compact('id'))));
|
||||
|
||||
return (new UsersTransformer)->transformUser($user);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue