public function authorize(
        string $action,
        $object,
        array $source = null
    ) {
        if ($this->request()->user()->cant($action, $object)) {
            throw new RequestFailedAuthorization(
                new Error(
                    $id = null,
                    $link = new Link('https://tools.ietf.org/html/rfc7231#section-6.5.3'),
                    $status = '403',
                    $code = null,
                    $title = 'Forbidden',
                    $desc = 'Access is denied for one or more of the specified resources',
                    $source,
                    $meta = null
                )
            );
        }

        return true;
    }
public function authorize(
        string $action,
        $object,
        array $source = null
    ) {
        if ($this->request()->user()->cant($action, $object)) {
            throw new RequestFailedAuthorization(
                new Error(
                    $id = null,
                    $link = new Link('https://tools.ietf.org/html/rfc7231#section-6.5.3'),
                    $status = '403',
                    $code = null,
                    $title = 'Forbidden',
                    $desc = 'Access is denied for one or more of the specified resources',
                    $source,
                    $meta = null
                )
            );
        }

        return true;
    }
public function authorize ( string $ action , $ object , array $ source = null ) { if ( $ this -> request ( ) -> user ( ) -> cant ( $ action , $ object ) ) { throw new RequestFailedAuthorization ( new Error ( $ id = null , $ link = new Link ( 'https://tools.ietf.org/html/rfc7231#section-6.5.3' ) , $ status = '403' , $ code = null , $ title = 'Forbidden' , $ desc = 'Access is denied for one or more of the specified resources' , $ source , $ meta = null ) ) ; } return true ; }
Ensure that a requested operation is authorized.
If not, throw an exception.

This requires a registered Policy.
If no policy is defined,
the framework will throw InvalidArgumentException.

See also:
https://laravel.com/docs/master/authorization
http://jsonapi.org/format/#errors

@param string $action Desired action; must match a policy method name.
@param mixed  $object Target object; class must match a policy.
@param array  $source Reference to source of error in request.

@return bool  True on success; throws exception on failure.

@throws RequestFailedAuthorization

TODO: use a UUID for the source?
Ensure that a requested operation is authorized . If not throw an exception .