Merge pull request #987 from SevanNerse/master

Middleware updated in order to decide that wizard is completed or not
This commit is contained in:
Denis Duliçi 2019-12-12 11:13:59 +03:00 committed by GitHub
commit 6697a2f67b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,4 @@
<?php
namespace App\Http\Middleware;
use Closure;
@ -7,6 +6,7 @@ use Illuminate\Support\Str;
class RedirectIfWizardCompleted
{
/**
* Handle an incoming request.
*
@ -16,17 +16,17 @@ class RedirectIfWizardCompleted
*/
public function handle($request, Closure $next)
{
// Not in wizard
if (!Str::startsWith($request->getPathInfo(), '/wizard')) {
// Check wizard is completed or not
if (setting('wizard.completed', 0) == 1) {
return $next($request);
}
// Wizard not completed
if (!setting('wizard.completed', 0)) {
// Already in the wizard
if (Str::startsWith($request->getPathInfo(), '/wizard')) {
return $next($request);
}
// Wizard completed, redirect to home
redirect()->intended('/')->send();
// Not wizard completed, redirect to wizard
redirect()->route('wizard.edit')->send();
}
}