Files
monica/app/Exceptions/Handler.php
T
webdistortionandRégis Freyd bb297d0c06 Token mismatch fix (#152)
I've named the route for this just to make the code a bit more readable. I think the problem is due to sessions expiring prior to people submitting the form and thus the token on the other side is dead causing the exception.

Fix #141
2017-06-08 23:37:58 -04:00

57 lines
1.4 KiB
PHP

<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Validation\ValidationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
AuthorizationException::class,
HttpException::class,
ModelNotFoundException::class,
ValidationException::class,
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
parent::report($e);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
// hopefully catches those pesky token expiries
// and send them back to login.
if ( $e instanceof TokenMismatchException ){
return redirect('login');
}
return parent::render($request, $e);
}
}