use BookStack\Access\LoginService;
use BookStack\Access\RegistrationService;
use BookStack\Api\ApiTokenGuard;
+use BookStack\Users\Models\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\ServiceProvider;
use Illuminate\Validation\Rules\Password;
{
/**
* Bootstrap the application services.
- *
- * @return void
*/
- public function boot()
+ public function boot(): void
{
// Password Configuration
// Changes here must be reflected in ApiDocsGenerate@getValidationAsString.
/**
* Register the application services.
- *
- * @return void
*/
- public function register()
+ public function register(): void
{
Auth::provider('external-users', function ($app, array $config) {
return new ExternalBaseUserProvider($config['model']);
});
+
+ // Bind and provide the default system user as a singleton to the app instance when needed.
+ // This effectively "caches" fetching the user at an app-instance level.
+ $this->app->singleton('users.default', function () {
+ return User::query()->where('system_name', '=', 'public')->first();
+ });
}
}