mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-07 13:41:23 +00:00
Improve installed database detection
This commit is contained in:
@@ -4,6 +4,7 @@ namespace InvoiceShelf\Http\Controllers\V1\Installation;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use InvoiceShelf\Http\Controllers\Controller;
|
||||
use InvoiceShelf\Space\InstallUtils;
|
||||
|
||||
class FinishController extends Controller
|
||||
{
|
||||
@@ -14,7 +15,7 @@ class FinishController extends Controller
|
||||
*/
|
||||
public function __invoke(Request $request)
|
||||
{
|
||||
\Storage::disk('local')->put('database_created', 'database_created');
|
||||
InstallUtils::createDbMarker();
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
}
|
||||
|
||||
@@ -5,17 +5,18 @@ namespace InvoiceShelf\Http\Controllers\V1\Installation;
|
||||
use Illuminate\Http\Request;
|
||||
use InvoiceShelf\Http\Controllers\Controller;
|
||||
use InvoiceShelf\Models\Setting;
|
||||
use InvoiceShelf\Space\InstallUtils;
|
||||
|
||||
class OnboardingWizardController extends Controller
|
||||
{
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function getStep(Request $request)
|
||||
{
|
||||
if (! \Storage::disk('local')->has('database_created')) {
|
||||
if (! InstallUtils::dbMarkerExists()) {
|
||||
return response()->json([
|
||||
'profile_complete' => 0,
|
||||
]);
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace InvoiceShelf\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use InvoiceShelf\Models\FileDisk;
|
||||
use InvoiceShelf\Space\InstallUtils;
|
||||
|
||||
class ConfigMiddleware
|
||||
{
|
||||
@@ -15,7 +16,7 @@ class ConfigMiddleware
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (\Storage::disk('local')->has('database_created')) {
|
||||
if (InstallUtils::isDbCreated()) {
|
||||
if ($request->has('file_disk_id')) {
|
||||
$file_disk = FileDisk::find($request->file_disk_id);
|
||||
} else {
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace InvoiceShelf\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use InvoiceShelf\Models\Setting;
|
||||
use InvoiceShelf\Space\InstallUtils;
|
||||
|
||||
class InstallationMiddleware
|
||||
{
|
||||
@@ -15,14 +16,12 @@ class InstallationMiddleware
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (! \Storage::disk('local')->has('database_created')) {
|
||||
return redirect('/installation');
|
||||
}
|
||||
|
||||
if (\Storage::disk('local')->has('database_created')) {
|
||||
if (Setting::getSetting('profile_complete') !== 'COMPLETED') {
|
||||
return redirect('/installation');
|
||||
if (! InstallUtils::isDbCreated() || Setting::getSetting('profile_complete') !== 'COMPLETED') {
|
||||
if (InstallUtils::dbMarkerExists()) {
|
||||
InstallUtils::deleteDbMarker();
|
||||
}
|
||||
|
||||
return redirect('/installation');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace InvoiceShelf\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use InvoiceShelf\Models\Setting;
|
||||
use InvoiceShelf\Space\InstallUtils;
|
||||
|
||||
class RedirectIfInstalled
|
||||
{
|
||||
@@ -15,7 +16,7 @@ class RedirectIfInstalled
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (\Storage::disk('local')->has('database_created')) {
|
||||
if (InstallUtils::dbMarkerExists()) {
|
||||
if (Setting::getSetting('profile_complete') === 'COMPLETED') {
|
||||
return redirect('login');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user