diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 287a96dc..45b5c22c 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -5,6 +5,7 @@ namespace App\Exceptions; use Exception; use Illuminate\Http\Response; use App\Exceptions\PrettyPageException; +use Illuminate\Session\TokenMismatchException; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Foundation\Validation\ValidationException; use Symfony\Component\HttpKernel\Exception\HttpException; @@ -22,6 +23,7 @@ class Handler extends ExceptionHandler protected $dontReport = [ HttpException::class, ModelNotFoundException::class, + TokenMismatchException::class, ValidationException::class, PrettyPageException::class, MethodNotAllowedHttpException::class, @@ -52,7 +54,11 @@ class Handler extends ExceptionHandler } if ($e instanceof MethodNotAllowedHttpException) { - abort(403, 'Method not allowed.'); + abort(403, trans('errors.http.method-not-allowed')); + } + + if ($e instanceof TokenMismatchException) { + return json(trans('errors.http.csrf-token-mismatch'), 1); } if ($e instanceof PrettyPageException) { diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 8e45f39c..9b7f383f 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -31,6 +31,7 @@ class Kernel extends HttpKernel \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\AfterSessionBooted::class, \App\Http\Middleware\DetectLanguagePrefer::class, + \App\Http\Middleware\VerifyCsrfToken::class, ], 'static' => [], diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php new file mode 100644 index 00000000..bcb9ceec --- /dev/null +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -0,0 +1,17 @@ +@yield('title') - {{ option_localized('site_name') }} {!! bs_favicon() !!} - + + @include('common.dependencies.style', ['module' => 'admin']) diff --git a/resources/views/auth/master.blade.php b/resources/views/auth/master.blade.php index b97c00ff..c15a617d 100644 --- a/resources/views/auth/master.blade.php +++ b/resources/views/auth/master.blade.php @@ -5,7 +5,8 @@