Cake\Controller\Component\AuthComponent::isAuthorized PHP Method

isAuthorized() public method

Uses the configured Authorization adapters to check whether or not a user is authorized. Each adapter will be checked in sequence, if any of them return true, then the user will be authorized for the request.
public isAuthorized ( array | ArrayAccess | null $user = null, Cake\Network\Request $request = null ) : boolean
$user array | ArrayAccess | null The user to check the authorization of. If empty the user fetched from storage will be used.
$request Cake\Network\Request The request to authenticate for. If empty, the current request will be used.
return boolean True if $user is authorized, otherwise false
    public function isAuthorized($user = null, Request $request = null)
    {
        if (empty($user) && !$this->user()) {
            return false;
        }
        if (empty($user)) {
            $user = $this->user();
        }
        if (empty($request)) {
            $request = $this->request;
        }
        if (empty($this->_authorizeObjects)) {
            $this->constructAuthorize();
        }
        foreach ($this->_authorizeObjects as $authorizer) {
            if ($authorizer->authorize($user, $request) === true) {
                $this->_authorizationProvider = $authorizer;
                return true;
            }
        }
        return false;
    }