setup
This commit is contained in:
@@ -22,7 +22,8 @@ readonly class AuthServiceLunar implements AuthService
|
|||||||
} elseif (request()->segment(1) !== "lucent") {
|
} elseif (request()->segment(1) !== "lucent") {
|
||||||
return config("lucent.systemUserId");
|
return config("lucent.systemUserId");
|
||||||
}
|
}
|
||||||
return Filament::auth()->user()->id;
|
|
||||||
|
return Filament::auth()->user()->id ?? null;
|
||||||
}
|
}
|
||||||
public function getCurrentUser(): User
|
public function getCurrentUser(): User
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,17 +2,13 @@
|
|||||||
|
|
||||||
namespace Lucent\Http\Controller;
|
namespace Lucent\Http\Controller;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
|
||||||
use Lucent\Account\AccountService;
|
use Lucent\Account\AccountService;
|
||||||
use Lucent\Channel\ChannelService;
|
use Lucent\Channel\ChannelService;
|
||||||
use Lucent\LucentException;
|
|
||||||
use Lucent\Setup\Data\SetupStep;
|
use Lucent\Setup\Data\SetupStep;
|
||||||
use Lucent\Setup\Data\SetupStepStatus;
|
use Lucent\Setup\Data\SetupStepStatus;
|
||||||
use Lucent\Setup\Setup;
|
|
||||||
use Lucent\Setup\Step\ComposerStep;
|
use Lucent\Setup\Step\ComposerStep;
|
||||||
use Lucent\Setup\Step\DatabaseSetupStep;
|
use Lucent\Setup\Step\DatabaseSetupStep;
|
||||||
use Lucent\Setup\Step\IStep;
|
use Lucent\Setup\Step\IStep;
|
||||||
@@ -21,38 +17,44 @@ use Lucent\Setup\Step\LucentConfigStep;
|
|||||||
use Lucent\Setup\Step\StorageLinkSetupStep;
|
use Lucent\Setup\Step\StorageLinkSetupStep;
|
||||||
use Lucent\Setup\Step\StorageSetupStep;
|
use Lucent\Setup\Step\StorageSetupStep;
|
||||||
use Lucent\Svelte\Svelte;
|
use Lucent\Svelte\Svelte;
|
||||||
use function Lucent\Response\fail;
|
|
||||||
use function Lucent\Response\ok;
|
|
||||||
|
|
||||||
|
|
||||||
class SetupController
|
class SetupController
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly AccountService $accountService,
|
private readonly AccountService $accountService,
|
||||||
private readonly ChannelService $channelService,
|
private readonly ChannelService $channelService,
|
||||||
private readonly Svelte $svelte,
|
private readonly Svelte $svelte,
|
||||||
)
|
) {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setup(Request $request): View|RedirectResponse
|
public function setup(Request $request): View|RedirectResponse
|
||||||
{
|
{
|
||||||
|
$steps = array_reduce(
|
||||||
|
[
|
||||||
|
new ComposerStep(),
|
||||||
|
new LucentConfigStep(),
|
||||||
|
new LaravelEnvStep(),
|
||||||
|
new StorageSetupStep(),
|
||||||
|
new StorageLinkSetupStep(),
|
||||||
|
new DatabaseSetupStep(),
|
||||||
|
],
|
||||||
|
fn(array $carry, IStep $setupStep) => array_merge($carry, [
|
||||||
|
$setupStep(),
|
||||||
|
]),
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
$allSuccess = array_reduce(
|
||||||
|
$steps,
|
||||||
|
fn(bool $carry, SetupStep $step) => !$carry
|
||||||
|
? false
|
||||||
|
: $step->status === SetupStepStatus::SUCCESS,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($allSuccess) {
|
||||||
$steps = array_reduce([
|
|
||||||
new ComposerStep,
|
|
||||||
new LucentConfigStep,
|
|
||||||
new LaravelEnvStep,
|
|
||||||
new StorageSetupStep,
|
|
||||||
new StorageLinkSetupStep,
|
|
||||||
new DatabaseSetupStep,
|
|
||||||
], fn(array $carry, IStep $setupStep) => array_merge($carry, [$setupStep()]), []);
|
|
||||||
$allSuccess = array_reduce($steps, fn(bool $carry, SetupStep $step) => !$carry ? false : $step->status === SetupStepStatus::SUCCESS, true);
|
|
||||||
|
|
||||||
if($allSuccess){
|
|
||||||
if ($this->accountService->countUsers() > 0) {
|
if ($this->accountService->countUsers() > 0) {
|
||||||
return redirect($this->channelService->channel->lucentUrl . "/login");
|
return redirect(
|
||||||
|
$this->channelService->channel->lucentUrl . "/login",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,10 +65,7 @@ class SetupController
|
|||||||
data: [
|
data: [
|
||||||
"steps" => $steps,
|
"steps" => $steps,
|
||||||
"allSuccess" => $allSuccess,
|
"allSuccess" => $allSuccess,
|
||||||
]
|
],
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,7 @@ use Lucent\Account\AuthService;
|
|||||||
|
|
||||||
readonly class GuestMiddleware
|
readonly class GuestMiddleware
|
||||||
{
|
{
|
||||||
public function __construct(private AuthService $authService)
|
public function __construct(private AuthService $authService) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle(Request $request, Closure $next)
|
public function handle(Request $request, Closure $next)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user