mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-31 15:24:31 +03:00
Guest control: Cleaned methods involved in fetching/handling
- Moves guest user caching from User class to app container for simplicity. - Updates test to use simpler $this->users->guest() method for consistency. - Streamlined helpers to avoid function overlap for simplicity. - Extracted user profile dropdown while doing changes.
This commit is contained in:
@ -9,6 +9,7 @@ use BookStack\Access\LdapService;
|
||||
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;
|
||||
@ -65,5 +66,11 @@ class AuthServiceProvider extends ServiceProvider
|
||||
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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user