From 26f23c825a7c1daa43f7c885da84623ffcc2f556 Mon Sep 17 00:00:00 2001 From: Kwesi Banson Jnr Date: Mon, 31 Aug 2026 15:40:36 +0000 Subject: [PATCH] bug fix on MNO module --- .../NetworkOperatorsController.php | 2 +- bootstrap/app.php | 25 +++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/NetworkOperatorsController.php b/app/Http/Controllers/NetworkOperatorsController.php index 4cff93d..283bef4 100644 --- a/app/Http/Controllers/NetworkOperatorsController.php +++ b/app/Http/Controllers/NetworkOperatorsController.php @@ -94,7 +94,7 @@ class NetworkOperatorsController extends Controller 'services' => $request->services, 'support_emails' => $request->support_emails, 'finance_emails' => $request->finance_emails, - 'buying_rate' => $request->buying_rate, + 'buying_rate' => $request->buying_rate ?? 0, 'rate_type' => $request->rate_type, 'payment_terms' => $request->payment_terms, 'connection_type' => $request->connection_type, diff --git a/bootstrap/app.php b/bootstrap/app.php index 7b162da..bdb67b2 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -3,6 +3,8 @@ use Illuminate\Foundation\Application; use Illuminate\Foundation\Configuration\Exceptions; use Illuminate\Foundation\Configuration\Middleware; +use Symfony\Component\HttpKernel\Exception\HttpException; +use Illuminate\Http\Request; return Application::configure(basePath: dirname(__DIR__)) ->withRouting( @@ -14,5 +16,24 @@ return Application::configure(basePath: dirname(__DIR__)) // }) ->withExceptions(function (Exceptions $exceptions) { - // - })->create(); + $exceptions->render(function (HttpException $e, Request $request) { + if ($e->getStatusCode() === 419) { + + if ($request->expectsJson()) { + return response()->json([ + 'message' => 'Your session has expired. Please refresh the page and try again.' + ], 419); + } + + // fallback('/login') ensures that if the session was completely lost, + // it defaults back to the login page instead of crashing or going to the root URL. + // return redirect()->back()->fallback('/login') + // ->withInput($request->except('password')) + // ->withErrors(['email' => 'Your session expired due to inactivity. Please try logging in again.']); + // The third parameter sets '/login' as the fallback if the Referer header is missing + return redirect()->back(302, [], '/login') + ->withInput($request->except('password')) + ->withErrors(['email' => 'Your session expired due to inactivity. Please try logging in again.']); + } + }); + })->create(); \ No newline at end of file