From 8afdce2ef1177ecbd43ad7aba2d1baa686d7dfc3 Mon Sep 17 00:00:00 2001 From: Marcel Folaron Date: Sat, 25 May 2024 17:56:35 -0400 Subject: [PATCH] [cleanup] code cleanup --- app/Core/ConsoleKernel.php | 10 ++++++++++ app/Core/Middleware/Installed.php | 6 ++++++ app/Domain/Auth/Controllers/Login.php | 5 ++++- app/Domain/Install/Controllers/Index.php | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/Core/ConsoleKernel.php b/app/Core/ConsoleKernel.php index c9a313fe5..e357c291c 100644 --- a/app/Core/ConsoleKernel.php +++ b/app/Core/ConsoleKernel.php @@ -108,6 +108,11 @@ public static function artisanBinary() }); } + /** + * Load and register the commands for the application. + * + * @return void + */ protected function commands() { static $commandsLoaded; @@ -181,6 +186,11 @@ protected function commands() $commandsLoaded = true; } + /** + * Schedule tasks to be executed. + * + * @return void + */ private function schedule() { // Set default timezone diff --git a/app/Core/Middleware/Installed.php b/app/Core/Middleware/Installed.php index 1f13d7ee2..1c86bb876 100644 --- a/app/Core/Middleware/Installed.php +++ b/app/Core/Middleware/Installed.php @@ -52,6 +52,12 @@ public function handle(IncomingRequest $request, Closure $next): Response \Illuminate\Support\Facades\Cache::set('installed', true); + $route = Frontcontroller::getCurrentRoute(); + + if($session_says && $route == "install") { + return Frontcontroller::redirect(BASE_URL . "/auth/logout"); + } + return $next($request); } diff --git a/app/Domain/Auth/Controllers/Login.php b/app/Domain/Auth/Controllers/Login.php index df55e3948..5269fc64c 100644 --- a/app/Domain/Auth/Controllers/Login.php +++ b/app/Domain/Auth/Controllers/Login.php @@ -56,7 +56,10 @@ public function get(array $params): Response $url = urldecode($_GET['redirect']); //Check for open redirects, don't allow redirects to external sites. - if (filter_var($url, FILTER_VALIDATE_URL) === false) { + if ( + filter_var($url, FILTER_VALIDATE_URL) === false && + !in_array($url, ["/auth/logout"]) + ) { $redirectUrl = BASE_URL ."/" . $url; } } diff --git a/app/Domain/Install/Controllers/Index.php b/app/Domain/Install/Controllers/Index.php index 3f6ab93a2..c5d4096aa 100644 --- a/app/Domain/Install/Controllers/Index.php +++ b/app/Domain/Install/Controllers/Index.php @@ -26,7 +26,7 @@ public function init(InstallRepository $installRepo) $this->installRepo = $installRepo; if ($this->installRepo->checkIfInstalled()) { - return FrontcontrollerCore::redirect(BASE_URL); + return FrontcontrollerCore::redirect(BASE_URL . "/"); } }