- Corregir middleware Authenticate para retornar JSON 401 en rutas API - Agregar método unauthenticated() en Handler para respuestas JSON - Implementar bypass de pago en ContractController - Corregir relaciones belongsToMany en Postulations y Suppliers - Corregir concatenación de strings en NoHomeController Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
70 lines
1.7 KiB
PHP
Executable File
70 lines
1.7 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Exceptions;
|
|
|
|
use Throwable;
|
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
|
use Illuminate\Auth\AuthenticationException;
|
|
|
|
class Handler extends ExceptionHandler
|
|
{
|
|
/**
|
|
* A list of the exception types that are not reported.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $dontReport = [
|
|
//
|
|
];
|
|
|
|
/**
|
|
* A list of the inputs that are never flashed for validation exceptions.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $dontFlash = [
|
|
'password',
|
|
'password_confirmation',
|
|
];
|
|
|
|
/**
|
|
* Report or log an exception.
|
|
*
|
|
* @param \Exception $exception
|
|
* @return void
|
|
*/
|
|
public function report(Throwable $exception)
|
|
{
|
|
parent::report($exception);
|
|
}
|
|
|
|
/**
|
|
* Render an exception into an HTTP response.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Exception $exception
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function render($request, Throwable $exception)
|
|
{
|
|
return parent::render($request, $exception);
|
|
}
|
|
|
|
/**
|
|
* Convert an authentication exception into a response.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Illuminate\Auth\AuthenticationException $exception
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
protected function unauthenticated($request, AuthenticationException $exception)
|
|
{
|
|
// Para rutas API, siempre retornar JSON
|
|
if ($request->is('api/*') || $request->expectsJson()) {
|
|
return response()->json(['message' => 'Unauthenticated.'], 401);
|
|
}
|
|
|
|
return redirect()->guest(route('login'));
|
|
}
|
|
}
|