mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-04-21 03:30:38 +00:00
Updated with latest styleci changes
This commit is contained in:
parent
c6ad16dba6
commit
045710ea08
9 changed files with 76 additions and 68 deletions
app
Api
Auth
Http/Controllers
tests
|
@ -129,6 +129,7 @@ class ApiDocsGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
$class = get_class($validation);
|
$class = get_class($validation);
|
||||||
|
|
||||||
throw new Exception("Cannot provide string representation of rule for class: {$class}");
|
throw new Exception("Cannot provide string representation of rule for class: {$class}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,8 @@ class ListingResponseBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a callback to modify each element of the results
|
* Add a callback to modify each element of the results.
|
||||||
|
*
|
||||||
* @param (callable(Model)) $modifier
|
* @param (callable(Model)) $modifier
|
||||||
*/
|
*/
|
||||||
public function modifyResults($modifier): void
|
public function modifyResults($modifier): void
|
||||||
|
|
|
@ -60,7 +60,7 @@ class UserRepo
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all users as Builder for API
|
* Get all users as Builder for API.
|
||||||
*/
|
*/
|
||||||
public function getApiUsersBuilder(): Builder
|
public function getApiUsersBuilder(): Builder
|
||||||
{
|
{
|
||||||
|
@ -159,6 +159,7 @@ class UserRepo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new basic instance of user with the given pre-validated data.
|
* Create a new basic instance of user with the given pre-validated data.
|
||||||
|
*
|
||||||
* @param array{name: string, email: string, password: ?string, external_auth_id: ?string, language: ?string, roles: ?array} $data
|
* @param array{name: string, email: string, password: ?string, external_auth_id: ?string, language: ?string, roles: ?array} $data
|
||||||
*/
|
*/
|
||||||
public function createWithoutActivity(array $data, bool $emailConfirmed = false): User
|
public function createWithoutActivity(array $data, bool $emailConfirmed = false): User
|
||||||
|
@ -188,6 +189,7 @@ class UserRepo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* As per "createWithoutActivity" but records a "create" activity.
|
* As per "createWithoutActivity" but records a "create" activity.
|
||||||
|
*
|
||||||
* @param array{name: string, email: string, password: ?string, external_auth_id: ?string, language: ?string, roles: ?array} $data
|
* @param array{name: string, email: string, password: ?string, external_auth_id: ?string, language: ?string, roles: ?array} $data
|
||||||
*/
|
*/
|
||||||
public function create(array $data, bool $sendInvite = false): User
|
public function create(array $data, bool $sendInvite = false): User
|
||||||
|
@ -199,12 +201,15 @@ class UserRepo
|
||||||
}
|
}
|
||||||
|
|
||||||
Activity::add(ActivityType::USER_CREATE, $user);
|
Activity::add(ActivityType::USER_CREATE, $user);
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the given user with the given data.
|
* Update the given user with the given data.
|
||||||
|
*
|
||||||
* @param array{name: ?string, email: ?string, external_auth_id: ?string, password: ?string, roles: ?array<int>, language: ?string} $data
|
* @param array{name: ?string, email: ?string, external_auth_id: ?string, password: ?string, roles: ?array<int>, language: ?string} $data
|
||||||
|
*
|
||||||
* @throws UserUpdateException
|
* @throws UserUpdateException
|
||||||
*/
|
*/
|
||||||
public function update(User $user, array $data, bool $manageUsersAllowed): User
|
public function update(User $user, array $data, bool $manageUsersAllowed): User
|
||||||
|
|
|
@ -16,7 +16,7 @@ class UserApiController extends ApiController
|
||||||
protected $userRepo;
|
protected $userRepo;
|
||||||
|
|
||||||
protected $fieldsToExpose = [
|
protected $fieldsToExpose = [
|
||||||
'email', 'created_at', 'updated_at', 'last_activity_at', 'external_auth_id'
|
'email', 'created_at', 'updated_at', 'last_activity_at', 'external_auth_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct(UserRepo $userRepo)
|
public function __construct(UserRepo $userRepo)
|
||||||
|
@ -27,6 +27,7 @@ class UserApiController extends ApiController
|
||||||
$this->middleware(function ($request, $next) {
|
$this->middleware(function ($request, $next) {
|
||||||
$this->checkPermission('users-manage');
|
$this->checkPermission('users-manage');
|
||||||
$this->preventAccessInDemoMode();
|
$this->preventAccessInDemoMode();
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -37,7 +38,7 @@ class UserApiController extends ApiController
|
||||||
'create' => [
|
'create' => [
|
||||||
'name' => ['required', 'min:2'],
|
'name' => ['required', 'min:2'],
|
||||||
'email' => [
|
'email' => [
|
||||||
'required', 'min:2', 'email', new Unique('users', 'email')
|
'required', 'min:2', 'email', new Unique('users', 'email'),
|
||||||
],
|
],
|
||||||
'external_auth_id' => ['string'],
|
'external_auth_id' => ['string'],
|
||||||
'language' => ['string'],
|
'language' => ['string'],
|
||||||
|
@ -51,7 +52,7 @@ class UserApiController extends ApiController
|
||||||
'email' => [
|
'email' => [
|
||||||
'min:2',
|
'min:2',
|
||||||
'email',
|
'email',
|
||||||
(new Unique('users', 'email'))->ignore($userId ?? null)
|
(new Unique('users', 'email'))->ignore($userId ?? null),
|
||||||
],
|
],
|
||||||
'external_auth_id' => ['string'],
|
'external_auth_id' => ['string'],
|
||||||
'language' => ['string'],
|
'language' => ['string'],
|
||||||
|
@ -113,6 +114,7 @@ class UserApiController extends ApiController
|
||||||
/**
|
/**
|
||||||
* Update an existing user in the system.
|
* Update an existing user in the system.
|
||||||
* Requires permission to manage users.
|
* Requires permission to manage users.
|
||||||
|
*
|
||||||
* @throws UserUpdateException
|
* @throws UserUpdateException
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, string $id)
|
public function update(Request $request, string $id)
|
||||||
|
|
|
@ -54,6 +54,7 @@ abstract class Controller extends BaseController
|
||||||
protected function showPermissionError()
|
protected function showPermissionError()
|
||||||
{
|
{
|
||||||
$message = request()->wantsJson() ? trans('errors.permissionJson') : trans('errors.permission');
|
$message = request()->wantsJson() ? trans('errors.permissionJson') : trans('errors.permission');
|
||||||
|
|
||||||
throw new NotifyException($message, '/', 403);
|
throw new NotifyException($message, '/', 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ class UsersApiTest extends TestCase
|
||||||
[
|
[
|
||||||
'id' => $role->id,
|
'id' => $role->id,
|
||||||
'display_name' => $role->display_name,
|
'display_name' => $role->display_name,
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
$this->assertDatabaseHas('users', ['email' => 'bboris@example.com']);
|
$this->assertDatabaseHas('users', ['email' => 'bboris@example.com']);
|
||||||
|
@ -166,7 +166,7 @@ class UsersApiTest extends TestCase
|
||||||
[
|
[
|
||||||
'id' => $userRole->id,
|
'id' => $userRole->id,
|
||||||
'display_name' => $userRole->display_name,
|
'display_name' => $userRole->display_name,
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ namespace Tests;
|
||||||
|
|
||||||
class HelpTest extends TestCase
|
class HelpTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
public function test_wysiwyg_help_shows_tiny_and_tiny_license_link()
|
public function test_wysiwyg_help_shows_tiny_and_tiny_license_link()
|
||||||
{
|
{
|
||||||
$resp = $this->get('/help/wysiwyg');
|
$resp = $this->get('/help/wysiwyg');
|
||||||
|
@ -21,5 +20,4 @@ class HelpTest extends TestCase
|
||||||
$contents = file_get_contents($expectedPath);
|
$contents = file_get_contents($expectedPath);
|
||||||
$this->assertStringContainsString('GNU LESSER GENERAL PUBLIC LICENSE', $contents);
|
$this->assertStringContainsString('GNU LESSER GENERAL PUBLIC LICENSE', $contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue