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;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
use Illuminate\Session\TokenMismatchException;
class VerifyCsrfToken extends Middleware
{
@@ -11,7 +12,19 @@ class VerifyCsrfToken extends Middleware
*
* @var array
*/
protected $except = [
protected $except = [
'/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.');
}
}
}