mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Test API Endpoint for users
This commit is contained in:
parent
95798a2eba
commit
07626669da
@ -61,6 +61,14 @@ class UserRepo
|
|||||||
return User::query()->with('roles', 'avatar')->orderBy('name', 'asc')->get();
|
return User::query()->with('roles', 'avatar')->orderBy('name', 'asc')->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all users as Builder for API
|
||||||
|
*/
|
||||||
|
public function getUsersBuilder(): Builder
|
||||||
|
{
|
||||||
|
$query = User::query()->select(['*']);
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Get all the users with their permissions in a paginated format.
|
* Get all the users with their permissions in a paginated format.
|
||||||
*/
|
*/
|
||||||
|
42
app/Http/Controllers/Api/UserApiController.php
Normal file
42
app/Http/Controllers/Api/UserApiController.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BookStack\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use BookStack\Exceptions\PermissionsException;
|
||||||
|
use BookStack\Auth\User;
|
||||||
|
use BookStack\Auth\UserRepo;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class UserApiController extends ApiController
|
||||||
|
{
|
||||||
|
protected $user;
|
||||||
|
protected $userRepo;
|
||||||
|
|
||||||
|
# TBD: Endpoints to create / update users
|
||||||
|
# protected $rules = [
|
||||||
|
# 'create' => [
|
||||||
|
# ],
|
||||||
|
# 'update' => [
|
||||||
|
# ],
|
||||||
|
# ];
|
||||||
|
|
||||||
|
public function __construct(User $user, UserRepo $userRepo)
|
||||||
|
{
|
||||||
|
$this->user = $user;
|
||||||
|
$this->userRepo = $userRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a listing of pages visible to the user.
|
||||||
|
*/
|
||||||
|
public function list()
|
||||||
|
{
|
||||||
|
$users = $this->userRepo->getUsersBuilder();
|
||||||
|
|
||||||
|
return $this->apiListingResponse($users, [
|
||||||
|
'id', 'name', 'slug',
|
||||||
|
'email', 'created_at', 'updated_at',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -44,3 +44,5 @@ Route::post('shelves', 'BookshelfApiController@create');
|
|||||||
Route::get('shelves/{id}', 'BookshelfApiController@read');
|
Route::get('shelves/{id}', 'BookshelfApiController@read');
|
||||||
Route::put('shelves/{id}', 'BookshelfApiController@update');
|
Route::put('shelves/{id}', 'BookshelfApiController@update');
|
||||||
Route::delete('shelves/{id}', 'BookshelfApiController@delete');
|
Route::delete('shelves/{id}', 'BookshelfApiController@delete');
|
||||||
|
|
||||||
|
Route::get('users', 'UserApiController@list');
|
||||||
|
Loading…
Reference in New Issue
Block a user