Files
lucent-laravel/src/Http/Middleware/AuthMiddleware.php
T

32 lines
657 B
PHP
Raw Normal View History

2023-10-02 23:10:49 +03:00
<?php
namespace Lucent\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
2023-10-17 22:57:25 +03:00
use Lucent\Account\AccountService;
2023-10-02 23:10:49 +03:00
use Lucent\Account\AuthService;
use Lucent\Channel\ChannelService;
readonly class AuthMiddleware
{
2023-10-17 22:57:25 +03:00
public function __construct(
private AuthService $authService,
private ChannelService $channelService
)
2023-10-02 23:10:49 +03:00
{
}
public function handle(Request $request, Closure $next)
{
if (!$this->authService->isLoggedIn()) {
return redirect($this->channelService->channel->lucentUrl . "/login");
}
2023-10-18 01:54:24 +03:00
$this->authService->refreshSession();
2023-10-17 22:57:25 +03:00
2023-10-02 23:10:49 +03:00
return $next($request);
}
}