27 lines
763 B
PHP
27 lines
763 B
PHP
<?php
|
|
|
|
namespace App\Exceptions;
|
|
|
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
|
use Illuminate\Session\TokenMismatchException;
|
|
use Throwable;
|
|
|
|
class Handler extends ExceptionHandler
|
|
{
|
|
public function render($request, \Throwable $e)
|
|
{
|
|
if ($e instanceof TokenMismatchException) {
|
|
if ($request->expectsJson()) {
|
|
return response()->json([
|
|
'message' => 'session_expired',
|
|
'redirect' => route('login'),
|
|
], 419);
|
|
}
|
|
return redirect()
|
|
->route('login')
|
|
->with('warning', 'Deine Sitzung ist abgelaufen. Bitte melde dich erneut an.');
|
|
}
|
|
return parent::render($request, $e);
|
|
}
|
|
}
|