mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
Added license endpoint for users
This commit is contained in:
parent
db59106c3e
commit
779fc6d195
|
@ -13,6 +13,7 @@ use App\Models\Asset;
|
|||
use App\Http\Transformers\AssetsTransformer;
|
||||
use App\Http\Transformers\SelectlistTransformer;
|
||||
use App\Http\Transformers\AccessoriesTransformer;
|
||||
use App\Http\Transformers\LicensesTransformer;
|
||||
|
||||
class UsersController extends Controller
|
||||
{
|
||||
|
@ -355,6 +356,23 @@ class UsersController extends Controller
|
|||
return (new AccessoriesTransformer)->transformAccessories($accessories, $accessories->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return JSON containing a list of licenses assigned to a user.
|
||||
*
|
||||
* @author [N. Mathar] [<snipe@snipe.net>]
|
||||
* @since [v5.0]
|
||||
* @param $userId
|
||||
* @return string JSON
|
||||
*/
|
||||
public function licenses($id)
|
||||
{
|
||||
$this->authorize('view', User::class);
|
||||
$this->authorize('view', License::class);
|
||||
$user = User::where('id', $id)->withTrashed()->first();
|
||||
$licenses = $user->licenses()->get();
|
||||
return (new LicensesTransformer())->transformLicenses($licenses, $licenses->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the user's two-factor status
|
||||
*
|
||||
|
|
|
@ -741,6 +741,13 @@ Route::group(['prefix' => 'v1','namespace' => 'Api', 'middleware' => 'api'], fun
|
|||
]
|
||||
);
|
||||
|
||||
Route::get('{user}/licenses',
|
||||
[
|
||||
'as' => 'api.users.licenselist',
|
||||
'uses' => 'UsersController@licenses'
|
||||
]
|
||||
);
|
||||
|
||||
Route::post('{user}/upload',
|
||||
[
|
||||
'as' => 'api.users.uploads',
|
||||
|
|
Loading…
Reference in a new issue