Mejoras generales .w. se me olvida que agrego
This commit is contained in:
22
backend/app/Exceptions/NotAuthorizedException.php
Normal file
22
backend/app/Exceptions/NotAuthorizedException.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class NotAuthorizedException extends Exception {
|
||||
protected $user;
|
||||
|
||||
public function __construct($user) {
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
public function render($request) {
|
||||
$path = $request->getPathInfo();
|
||||
|
||||
return response()->json([
|
||||
'error' => 'not_authorized',
|
||||
'message' => 'El usuario ' . $this->user->id . ' no tiene permiso para acceder al endpoint ' . $path
|
||||
], 401);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user