feat: Face ID (scan, register, liveness) + role baru KS/Waka/Ketua Tim + notifikasi WA ortu + scoping wali kelas + error pages premium
This commit is contained in:
@@ -4,6 +4,9 @@ use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
@@ -25,4 +28,39 @@ return Application::configure(basePath: dirname(__DIR__))
|
||||
$exceptions->shouldRenderJsonWhen(
|
||||
fn (Request $request) => $request->is('api/*'),
|
||||
);
|
||||
|
||||
// Halaman error ramah user (kecuali permintaan JSON)
|
||||
$htmlView = function (string $view, int $code, Request $request): ?\Illuminate\Http\Response {
|
||||
if ($request->expectsJson() || $request->is('api/*')) {
|
||||
return null;
|
||||
}
|
||||
return response()->view($view, [], $code);
|
||||
};
|
||||
|
||||
$exceptions->renderable(function (NotFoundHttpException $e, Request $request) use ($htmlView) {
|
||||
return $htmlView('errors.404', 404, $request);
|
||||
});
|
||||
$exceptions->renderable(function (AccessDeniedHttpException $e, Request $request) use ($htmlView) {
|
||||
return $htmlView('errors.403', 403, $request);
|
||||
});
|
||||
$exceptions->renderable(function (HttpException $e, Request $request) use ($htmlView) {
|
||||
$view = match ($e->getStatusCode()) {
|
||||
419 => 'errors.419',
|
||||
403 => 'errors.403',
|
||||
503 => 'errors.503',
|
||||
default => null,
|
||||
};
|
||||
if (!$view) {
|
||||
return null;
|
||||
}
|
||||
return $htmlView($view, $e->getStatusCode(), $request);
|
||||
});
|
||||
$exceptions->renderable(function (\Throwable $e, Request $request) use ($htmlView) {
|
||||
// Biarkan default menangani (redirect ke login)
|
||||
if ($e instanceof \Illuminate\Auth\AuthenticationException) {
|
||||
return null;
|
||||
}
|
||||
\Illuminate\Support\Facades\Log::error('Unhandled exception: ' . get_class($e) . ' - ' . $e->getMessage() . ' @ ' . $request->path());
|
||||
return $htmlView('errors.500', 500, $request);
|
||||
});
|
||||
})->create();
|
||||
|
||||
Reference in New Issue
Block a user