mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 23:23:52 +08:00
Split SessionServiceProvider from UserServiceProvider
This lets us register the former during installation, where the latter is not yet registered. That, in turn, means we can finally re-enable the StartSession middleware in the installer app, which we need to log in the new admin user when installation is complete.
This commit is contained in:
parent
98aaa6a130
commit
e65b3ac153
|
@ -29,6 +29,7 @@ use Flarum\Search\SearchServiceProvider;
|
|||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Flarum\Settings\SettingsServiceProvider;
|
||||
use Flarum\Update\UpdateServiceProvider;
|
||||
use Flarum\User\SessionServiceProvider;
|
||||
use Flarum\User\UserServiceProvider;
|
||||
use Illuminate\Cache\FileStore;
|
||||
use Illuminate\Cache\Repository as CacheRepository;
|
||||
|
@ -143,6 +144,7 @@ class InstalledSite implements SiteInterface
|
|||
$laravel->register(NotificationServiceProvider::class);
|
||||
$laravel->register(PostServiceProvider::class);
|
||||
$laravel->register(SearchServiceProvider::class);
|
||||
$laravel->register(SessionServiceProvider::class);
|
||||
$laravel->register(UserServiceProvider::class);
|
||||
$laravel->register(UpdateServiceProvider::class);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ use Flarum\Install\InstallServiceProvider;
|
|||
use Flarum\Locale\LocaleServiceProvider;
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Flarum\Settings\UninstalledSettingsRepository;
|
||||
use Flarum\User\SessionServiceProvider;
|
||||
use Illuminate\Config\Repository as ConfigRepository;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Filesystem\FilesystemServiceProvider;
|
||||
|
@ -79,6 +80,7 @@ class UninstalledSite implements SiteInterface
|
|||
|
||||
$laravel->register(LocaleServiceProvider::class);
|
||||
$laravel->register(FilesystemServiceProvider::class);
|
||||
$laravel->register(SessionServiceProvider::class);
|
||||
$laravel->register(ValidationServiceProvider::class);
|
||||
|
||||
$laravel->register(InstallServiceProvider::class);
|
||||
|
|
|
@ -38,7 +38,7 @@ class Installer implements AppInterface
|
|||
{
|
||||
$pipe = new MiddlewarePipe;
|
||||
$pipe->pipe($this->laravel->make(HandleErrorsWithWhoops::class));
|
||||
#$pipe->pipe($this->laravel->make(StartSession::class));
|
||||
$pipe->pipe($this->laravel->make(StartSession::class));
|
||||
$pipe->pipe(
|
||||
$this->laravel->make(
|
||||
DispatchRoute::class,
|
||||
|
|
35
framework/core/src/User/SessionServiceProvider.php
Normal file
35
framework/core/src/User/SessionServiceProvider.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\User;
|
||||
|
||||
use Flarum\Foundation\AbstractServiceProvider;
|
||||
use Illuminate\Session\FileSessionHandler;
|
||||
use SessionHandlerInterface;
|
||||
|
||||
class SessionServiceProvider extends AbstractServiceProvider
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton('session.handler', function ($app) {
|
||||
return new FileSessionHandler(
|
||||
$app['files'],
|
||||
$app['config']['session.files'],
|
||||
$app['config']['session.lifetime']
|
||||
);
|
||||
});
|
||||
|
||||
$this->app->alias('session.handler', SessionHandlerInterface::class);
|
||||
}
|
||||
}
|
|
@ -15,9 +15,7 @@ use Flarum\Event\ConfigureUserPreferences;
|
|||
use Flarum\Event\GetPermission;
|
||||
use Flarum\Foundation\AbstractServiceProvider;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Session\FileSessionHandler;
|
||||
use RuntimeException;
|
||||
use SessionHandlerInterface;
|
||||
|
||||
class UserServiceProvider extends AbstractServiceProvider
|
||||
{
|
||||
|
@ -26,24 +24,10 @@ class UserServiceProvider extends AbstractServiceProvider
|
|||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->registerSession();
|
||||
$this->registerGate();
|
||||
$this->registerAvatarsFilesystem();
|
||||
}
|
||||
|
||||
protected function registerSession()
|
||||
{
|
||||
$this->app->singleton('session.handler', function ($app) {
|
||||
return new FileSessionHandler(
|
||||
$app['files'],
|
||||
$app['config']['session.files'],
|
||||
$app['config']['session.lifetime']
|
||||
);
|
||||
});
|
||||
|
||||
$this->app->alias('session.handler', SessionHandlerInterface::class);
|
||||
}
|
||||
|
||||
protected function registerGate()
|
||||
{
|
||||
$this->app->singleton('flarum.gate', function ($app) {
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Flarum\Tests\Test\Concerns;
|
|||
use Flarum\Api\ApiServiceProvider;
|
||||
use Flarum\Api\Client;
|
||||
use Flarum\User\Guest;
|
||||
use Flarum\User\SessionServiceProvider;
|
||||
use Flarum\User\User;
|
||||
use Flarum\User\UserServiceProvider;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
@ -22,6 +23,7 @@ trait MakesApiRequests
|
|||
{
|
||||
public function call(string $controller, User $actor = null, array $queryParams = [], array $body = []): ResponseInterface
|
||||
{
|
||||
$this->app->register(SessionServiceProvider::class);
|
||||
$this->app->register(UserServiceProvider::class);
|
||||
$this->app->register(ApiServiceProvider::class);
|
||||
$this->app->make('flarum.api.middleware');
|
||||
|
|
Loading…
Reference in New Issue
Block a user