> */ protected $dontReport = [ // ]; /** * A list of the inputs that are never flashed for validation exceptions. * * @var array */ protected $dontFlash = [ 'current_password', 'password', 'password_confirmation', ]; /** * Register the exception handling callbacks for the application. * * @return void */ protected function unauthenticated($request, AuthenticationException $exception) { // Selalu kembalikan JSON untuk semua request API/mobile if ($request->expectsJson() || $request->is('api/*') || $request->is('mobile/*')) { return response()->json([ 'errors' => 'Token tidak valid atau telah kedaluwarsa', ], 401); } // Untuk request web, redirect ke login return redirect()->guest(route('login')); } public function register() { $this->reportable(function (Throwable $e) { // }); // Tambahkan handler untuk respons JSON universal $this->renderable(function (AuthenticationException $e, $request) { if ($request->expectsJson() || $request->is('api/*') || $request->is('mobile/*')) { return response()->json([ 'errors' => 'Token tidak valid atau telah kedaluwarsa', ], 401); } }); } }