misc_pterodactyl-panel/app/Http/Middleware/Authenticate.php
2017-11-03 18:16:49 -05:00

32 lines
749 B
PHP

<?php
namespace Pterodactyl\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Auth\AuthenticationException;
class Authenticate
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*
* @throws \Illuminate\Auth\AuthenticationException
*/
public function handle(Request $request, Closure $next)
{
if (! $request->user()) {
if ($request->ajax() || $request->expectsJson()) {
throw new AuthenticationException();
} else {
return redirect()->route('auth.login');
}
}
return $next($request);
}
}