Fix tests

This commit is contained in:
Julien Nahum 2024-01-19 15:15:38 +01:00
parent 5129149c6c
commit 43d731fb49
1 changed files with 7 additions and 2 deletions

View File

@ -4,6 +4,7 @@ namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Tymon\JWTAuth\Exceptions\JWTException;
class ImpersonationMiddleware
{
@ -64,10 +65,14 @@ class ImpersonationMiddleware
*/
public function handle(Request $request, Closure $next)
{
if (!auth()->check() ||
!auth()->payload()->get('impersonating')) {
try {
if (!auth()->check() || !auth()->payload()->get('impersonating')) {
return $next($request);
}
} catch (JWTException $e) {
return $next($request);
}
// Check that route is allowed
$routeName = $request->route()->getName();
if (!in_array($routeName, self::ALLOWED_ROUTES)) {