mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 17:24:10 +00:00
Refactor install wizard and mail configuration
This commit is contained in:
41
app/Http/Middleware/UseInstallWizardTokenAuth.php
Normal file
41
app/Http/Middleware/UseInstallWizardTokenAuth.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\Setting;
|
||||
use App\Services\Setup\InstallUtils;
|
||||
use App\Support\InstallWizardAuth;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class UseInstallWizardTokenAuth
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if (! InstallWizardAuth::isRequest($request) || ! $this->installationIsIncomplete()) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
config([
|
||||
'sanctum.guard' => [],
|
||||
'sanctum.stateful' => [],
|
||||
]);
|
||||
$request->attributes->set('install_wizard', true);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
private function installationIsIncomplete(): bool
|
||||
{
|
||||
if (! InstallUtils::isDbCreated()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
return Setting::getSetting('profile_complete') !== 'COMPLETED';
|
||||
} catch (\Exception $e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user