in Handler head:
use Illuminate\Auth\Access\AuthorizationException;
in handler render method:
if ($e instanceof AuthorizationException) {
return response()->json(['message' => $e->getMessage()], 403);
}
form request:
use Illuminate\Auth\Access\AuthorizationException;
class SomeFormRequest extends Request
{
public function authorize()
{
$this->error = 'some text';
return false;
}
protected function failedAuthorization()
{
throw new AuthorizationException($this->error);
}
}
and part of my output (it's error 500):
{
"message": {
"xdebug_message": "<tr><th align='left' bgcolor='#f57900' colspan=\"5\"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Illuminate\\Auth\\Access\\AuthorizationException: some text
Maybe you have some solution?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2GtDA7O
via IFTTT
Aucun commentaire:
Enregistrer un commentaire