lasthourcloud/app/Http/Middleware/SubscriptionValid.php

38 lines
938 B
PHP
Raw Normal View History

2023-07-13 22:03:27 +02:00
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class SubscriptionValid
{
2023-07-14 11:27:08 +02:00
2023-07-13 22:03:27 +02:00
public function handle(Request $request, Closure $next): Response
{
$allowed_paths = [
2023-07-14 11:27:08 +02:00
'subscription',
2023-07-13 22:03:27 +02:00
'login',
'register',
'logout',
2023-07-14 11:27:08 +02:00
'livewire/message/check-license',
'livewire/message/switch-team',
2023-07-13 22:03:27 +02:00
];
2023-07-14 11:27:08 +02:00
if (isCloud() && !isSubscribed()) {
ray('SubscriptionValid Middleware');
2023-07-13 22:03:27 +02:00
if (!in_array($request->path(), $allowed_paths)) {
2023-07-14 11:27:08 +02:00
return redirect('subscription');
} else {
return $next($request);
2023-07-13 22:03:27 +02:00
}
2023-07-14 11:27:08 +02:00
} else {
if ($request->path() === 'subscription') {
return redirect('/');
} else {
return $next($request);
2023-07-13 22:03:27 +02:00
}
}
}
2023-07-14 11:27:08 +02:00
}