43 lines
1.5 KiB
PHP
43 lines
1.5 KiB
PHP
<?php
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Foundation\Application;
|
|
use Illuminate\Foundation\Configuration\Exceptions;
|
|
use Illuminate\Foundation\Configuration\Middleware;
|
|
use Illuminate\Session\TokenMismatchException;
|
|
|
|
return Application::configure(basePath: dirname(__DIR__))
|
|
->withRouting(
|
|
web: __DIR__.'/../routes/web.php',
|
|
commands: __DIR__.'/../routes/console.php',
|
|
health: '/up',
|
|
)
|
|
->withMiddleware(function (Middleware $middleware): void {
|
|
$middleware->alias([
|
|
'akses.master' => \App\Http\Middleware\EnsureMasterAkses::class,
|
|
'master.persetujuan' => \App\Http\Middleware\EnsureMasterPersetujuan::class,
|
|
]);
|
|
})
|
|
->withExceptions(function (Exceptions $exceptions): void {
|
|
$exceptions->render(function (TokenMismatchException $exception, Request $request) {
|
|
$message = 'Sesi halaman sudah habis. Silakan login ulang.';
|
|
|
|
if ($request->is('login')) {
|
|
return redirect()
|
|
->route('login')
|
|
->withInput($request->only('namauser'))
|
|
->with('alertError', 'expired');
|
|
}
|
|
|
|
if (!$request->expectsJson()) {
|
|
return redirect()
|
|
->guest(route('login'))
|
|
->with('alertError', 'expired-session');
|
|
}
|
|
|
|
return response()->json([
|
|
'message' => $message,
|
|
], 419);
|
|
});
|
|
})->create();
|