lasthourcloud/app/Http/Middleware/SubscriptionValid.php
Andras Bacsai a378b5108e refactor a lot of things
fix: postgres_passwords could be longer
feat: able to define postgresql databases from the ui
2023-08-09 15:57:53 +02:00

42 lines
1.1 KiB
PHP

<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class SubscriptionValid
{
public function handle(Request $request, Closure $next): Response
{
if (auth()->user()) {
if (is_cloud() && !isSubscribed()) {
ray('SubscriptionValid Middleware');
$allowed_paths = [
'subscription',
'login',
'register',
'logout',
'livewire/message/check-license',
'livewire/message/switch-team',
];
if (!in_array($request->path(), $allowed_paths)) {
return redirect('subscription');
} else {
return $next($request);
}
} else {
if ($request->path() === 'subscription' && !auth()->user()->isInstanceAdmin()) {
return redirect('/');
} else {
return $next($request);
}
}
}
return $next($request);
}
}