added handled for page expired 419

This commit is contained in:
hafifierahman
2025-01-11 14:01:40 +08:00
parent 6c7de03c4e
commit b0272a8fa8
2 changed files with 20 additions and 1 deletions
+14 -1
View File
@@ -3,6 +3,7 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware; use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
use Illuminate\Session\TokenMismatchException;
class VerifyCsrfToken extends Middleware class VerifyCsrfToken extends Middleware
{ {
@@ -11,7 +12,19 @@ class VerifyCsrfToken extends Middleware
* *
* @var array * @var array
*/ */
protected $except = [
protected $except = [
'/pembayaran/backend' '/pembayaran/backend'
]; ];
public function handle($request, \Closure $next)
{
try {
return parent::handle($request, $next);
} catch (TokenMismatchException $e) {
// Redirect to login page if CSRF token is invalid
return redirect()->route('login')->with('logsemula', 'Sesi anda telah tamat. Sila log masuk semula.');
}
}
} }
@@ -13,6 +13,12 @@
<!-- <div style="text-align: center;"><img src="{{ asset('/argon/img/brand/arrahnpay3.png') }}" style="text-align: center;"></div> --> <!-- <div style="text-align: center;"><img src="{{ asset('/argon/img/brand/arrahnpay3.png') }}" style="text-align: center;"></div> -->
<h6 style="text-align: center; margin-bottom: 10%;">Log Masuk</h6> <h6 style="text-align: center; margin-bottom: 10%;">Log Masuk</h6>
@if(session('logsemula'))
<div class="alert alert-primary text-center font-weight-bold" style="font-size: 13px;color:white;">
{{ session('logsemula') }}
</div>
@endif
<form role="#" method="post" enctype="multipart/form-data" class="login-form" novalidate="novalidate"> <form role="#" method="post" enctype="multipart/form-data" class="login-form" novalidate="novalidate">
@csrf @csrf
<div class="input-group input-group-outline my-3 {{ $errors->has('email') ? ' has-danger' : '' }}"> <div class="input-group input-group-outline my-3 {{ $errors->has('email') ? ' has-danger' : '' }}">