diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 0ffabd7505..7dbe88804f 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -14,6 +14,7 @@ use App\Http\Requests\SaveUserRequest; use App\Models\Asset; use App\Http\Transformers\AssetsTransformer; use App\Http\Transformers\SelectlistTransformer; +use App\Http\Transformers\AccessoriesTransformer; class UsersController extends Controller { @@ -328,6 +329,24 @@ class UsersController extends Controller } /** + * Return JSON containing a list of accessories assigned to a user. + * + * @author [A. Gianotto] [] + * @since [v4.6.14] + * @param $userId + * @return string JSON + */ + public function accessories($id) + { + $this->authorize('view', User::class); + $user = User::findOrFail($id); + $this->authorize('view', Accessory::class); + $accessories = $user->accessories; + return (new AccessoriesTransformer)->transformAccessories($accessories, $accessories->count()); + } + + /** + * Return JSON containing a list of licenses assigned to a user. * * @author [N. Mathar] [] @@ -345,6 +364,8 @@ class UsersController extends Controller } /** + + * Reset the user's two-factor status * * @author [A. Gianotto] [] diff --git a/routes/api.php b/routes/api.php index 02dcab7494..da58760578 100644 --- a/routes/api.php +++ b/routes/api.php @@ -727,6 +727,7 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () { ] ); + Route::get('{user}/licenses', [ 'as' => 'api.users.licenselist', @@ -734,6 +735,14 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () { ] ); + + Route::get('{user}/accessories', + [ + 'as' => 'api.users.licenselist', + 'uses' => 'UsersController@licenses' + ] + ); + Route::post('{user}/upload', [ 'as' => 'api.users.uploads',