mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-04-15 17:24:11 +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);
|
||||
|
||||
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
|
||||
*/
|
||||
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
|
||||
{
|
||||
|
@ -159,6 +159,7 @@ class UserRepo
|
|||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function createWithoutActivity(array $data, bool $emailConfirmed = false): User
|
||||
|
@ -188,6 +189,7 @@ class UserRepo
|
|||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function create(array $data, bool $sendInvite = false): User
|
||||
|
@ -199,12 +201,15 @@ class UserRepo
|
|||
}
|
||||
|
||||
Activity::add(ActivityType::USER_CREATE, $user);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @throws UserUpdateException
|
||||
*/
|
||||
public function update(User $user, array $data, bool $manageUsersAllowed): User
|
||||
|
|
|
@ -16,7 +16,7 @@ class UserApiController extends ApiController
|
|||
protected $userRepo;
|
||||
|
||||
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)
|
||||
|
@ -27,6 +27,7 @@ class UserApiController extends ApiController
|
|||
$this->middleware(function ($request, $next) {
|
||||
$this->checkPermission('users-manage');
|
||||
$this->preventAccessInDemoMode();
|
||||
|
||||
return $next($request);
|
||||
});
|
||||
}
|
||||
|
@ -37,7 +38,7 @@ class UserApiController extends ApiController
|
|||
'create' => [
|
||||
'name' => ['required', 'min:2'],
|
||||
'email' => [
|
||||
'required', 'min:2', 'email', new Unique('users', 'email')
|
||||
'required', 'min:2', 'email', new Unique('users', 'email'),
|
||||
],
|
||||
'external_auth_id' => ['string'],
|
||||
'language' => ['string'],
|
||||
|
@ -51,7 +52,7 @@ class UserApiController extends ApiController
|
|||
'email' => [
|
||||
'min:2',
|
||||
'email',
|
||||
(new Unique('users', 'email'))->ignore($userId ?? null)
|
||||
(new Unique('users', 'email'))->ignore($userId ?? null),
|
||||
],
|
||||
'external_auth_id' => ['string'],
|
||||
'language' => ['string'],
|
||||
|
@ -113,6 +114,7 @@ class UserApiController extends ApiController
|
|||
/**
|
||||
* Update an existing user in the system.
|
||||
* Requires permission to manage users.
|
||||
*
|
||||
* @throws UserUpdateException
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
|
|
|
@ -54,6 +54,7 @@ abstract class Controller extends BaseController
|
|||
protected function showPermissionError()
|
||||
{
|
||||
$message = request()->wantsJson() ? trans('errors.permissionJson') : trans('errors.permission');
|
||||
|
||||
throw new NotifyException($message, '/', 403);
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ class UsersApiTest extends TestCase
|
|||
[
|
||||
'id' => $role->id,
|
||||
'display_name' => $role->display_name,
|
||||
]
|
||||
],
|
||||
],
|
||||
]);
|
||||
$this->assertDatabaseHas('users', ['email' => 'bboris@example.com']);
|
||||
|
@ -166,7 +166,7 @@ class UsersApiTest extends TestCase
|
|||
[
|
||||
'id' => $userRole->id,
|
||||
'display_name' => $userRole->display_name,
|
||||
]
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace Tests;
|
|||
|
||||
class HelpTest extends TestCase
|
||||
{
|
||||
|
||||
public function test_wysiwyg_help_shows_tiny_and_tiny_license_link()
|
||||
{
|
||||
$resp = $this->get('/help/wysiwyg');
|
||||
|
@ -21,5 +20,4 @@ class HelpTest extends TestCase
|
|||
$contents = file_get_contents($expectedPath);
|
||||
$this->assertStringContainsString('GNU LESSER GENERAL PUBLIC LICENSE', $contents);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue