Skip to content

A free open source IT asset/license management system

Fixed RB-20501 - correctly return error response when license+seat don’t match

snipe7f761981391a
diff --git a/app/Http/Controllers/Api/LicenseSeatsController.php b/app/Http/Controllers/Api/LicenseSeatsController.php
index 814d85cded..c2902ad031 100644
--- a/app/Http/Controllers/Api/LicenseSeatsController.php
+++ b/app/Http/Controllers/Api/LicenseSeatsController.php
@@ -79,17 +79,14 @@ class LicenseSeatsController extends Controller
{
$this->authorize('view', License::class);
- // sanity checks:
- // 1. does the license seat exist?
- if (! $licenseSeat = LicenseSeat::find($seatId)) {
- return response()->json(Helper::formatStandardApiResponse('error', null, 'Seat not found'));
- }
- // 2. does the seat belong to the specified license?
- if (! $licenseSeat = $licenseSeat->license()->first() || $licenseSeat->id != intval($licenseId)) {
- return response()->json(Helper::formatStandardApiResponse('error', null, 'Seat does not belong to the specified license'));
+
+ if ($licenseSeat = LicenseSeat::where('id',$seatId)->where('license_id', $licenseId)->first()) {
+ return (new LicenseSeatsTransformer)->transformLicenseSeat($licenseSeat);
}
- return (new LicenseSeatsTransformer)->transformLicenseSeat($licenseSeat);
+ return response()->json(Helper::formatStandardApiResponse('error', null, 'Seat ID or license not found or the seat does not belong to this license'));
+
+
}
/**