mirror of
https://github.com/koel/koel
synced 2024-12-21 01:53:11 +00:00
21 lines
449 B
PHP
21 lines
449 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Response;
|
|
|
|
class Authenticate
|
|
{
|
|
public function handle(Request $request, Closure $next) // @phpcs:ignore
|
|
{
|
|
if ($request->user()?->tokenCan('*')) {
|
|
return $next($request);
|
|
}
|
|
|
|
abort_if($request->ajax() || $request->wantsJson(), Response::HTTP_UNAUTHORIZED);
|
|
|
|
return redirect()->guest('/');
|
|
}
|
|
}
|