mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 05:47:28 -08:00
parent
fdd6ddf61b
commit
66f557d436
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Transformers\LicensesTransformer;
|
||||
use App\Models\License;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Transformers\UsersTransformer;
|
||||
|
@ -314,6 +316,23 @@ class UsersController extends Controller
|
|||
return (new AssetsTransformer)->transformAssets($assets, $assets->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
|
||||
*
|
||||
|
|
|
@ -684,7 +684,7 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
|
|||
|
||||
/*--- Users API ---*/
|
||||
|
||||
|
||||
|
||||
Route::group([ 'prefix' => 'users' ], function () {
|
||||
|
||||
Route::post('two_factor_reset',
|
||||
|
@ -722,6 +722,13 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
|
|||
]
|
||||
);
|
||||
|
||||
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