Check authorization.

@param  string  $action

@return bool
160295
protected function authorize(?string $action = null): bool
    {
        return $this->foundation->memory()->get('site.registrable', false);
    }
748506
private Access authorizationCheck(final HttpServletRequest req, Action action)
  {
    return IndexTaskUtils.datasourceAuthorizationCheck(req, action, task.getDataSource(), authorizerMapper);
  }
1293852
public function canExecute($action)
    {
        $method  = 'can'.ucfirst($action);
        $methods = $this->getMixer()->getMethods();

        if (!isset($methods[$method]))
        {
            $actions = $this->getActions();
            $actions = array_flip($actions);

            $result = isset($actions[$action]);
        }
        else $result = $this->$method();

        return $result;
    }
806263
protected function check($action)
	{
		$this->log('check', LOG_DEBUG);

		if (is_array($this->remote_host))
		{
			foreach ($this->remote_host as $key => $remote_host)
			{
				if ($key == 0) continue;

				$this->prepareRemoteDirectory($remote_host, $this->remote_dir);
			}
		}

		if ($action == 'update')
			$this->checkFiles(is_array($this->remote_host) ? $this->remote_host[0] : $this->remote_host, $this->remote_dir, $this->last_remote_target_dir);

		if ($action == 'update')
		{
			if (is_array($this->remote_host))
			{
				foreach ($this->remote_host as $remote_host)
				{
					if ($files = $this->listFilesToRename($remote_host, $this->remote_dir))
					{
						$this->log("Target-specific file renames on $remote_host:");

						foreach ($files as $filepath => $newpath)
							$this->log("  $newpath => $filepath");
					}
				}
			}
			else
			{
				if ($files = $this->listFilesToRename($this->remote_host, $this->remote_dir))
				{
					$this->log('Target-specific file renames:');

					foreach ($files as $filepath => $newpath)
						$this->log("  $newpath => $filepath");
				}
			}
		}

		// als alles goed is gegaan kan er doorgegaan worden met de deployment
		if ($action == 'update')
			return static::inputPrompt('Proceed with deployment? (yes/no): ', 'no') == 'yes';
		elseif ($action == 'rollback')
			return static::inputPrompt('Proceed with rollback? (yes/no): ', 'no') == 'yes';

        return false;
	}
454243
public function can(string $action, $entity): bool
	{
		return $this->authorizer->can($this, $action, $entity);
	}
761792
public function check()
    {
    	$action = $this->request->param('action');
        $controller = $this->request->param('controller');
        $prefix = ($this->request->param('prefix') === false) ? '/' : $this->request->param('prefix');
        $plugin = ($this->request->param('plugin') === false) ? '' : $this->request->param('plugin');

        $plugin_prefix = (empty($plugin)) ? $prefix : $plugin . '.' . $prefix;
        if( isset($this->_authorized[$plugin_prefix][$controller]) &&
            in_array($action, $this->_authorized[$plugin_prefix][$controller]) ) return true;

        $user_id = $this->request->session()->read('Auth.User.id');
        $group_id = -1;
        if( isset($this->controllers['group']) ) {
            $User = TableRegistry::get($this->controllers['user']);
            $group_id = $User->get($user_id)->group_id;
        }

        $UserGroupPermission = TableRegistry::get('UserGroupPermission');
        $Permission = TableRegistry::get('Permission');

        $unique_string = $this->getUniqueString($controller, $action, $prefix, $plugin);
        $permission_id = $Permission->find()
            ->select(['id'])
            ->where(['unique_string' => $unique_string])->first();
        if( is_null($permission_id) ) return false;

        $allow = $UserGroupPermission->find()
            ->select(['allow'])
            ->where(
                [
                    'group_or_user'     => 'user',
                    'group_or_user_id'  => $user_id,

                ])
            ->orWhere(
                [
                    'group_or_user'     => 'group',
                    'group_or_user_id'  => $group_id
                ])->andWhere(['permission_id' => $permission_id->id])
            ->order(['allow'=>'DESC'])->first();
        if( is_null($allow) ) return false;

        return $allow->allow;
    }
511843
public function canIfAs(Authorizable $user, string $action): bool
    {
        $this->setUser($user);

        $permission = $this->canIf($action);

        $this->revokeUser();

        return $permission;
    }
277822
public function checkMethod($action): bool {
        $methods = $this->methods();
        return !isset($methods[$action]) ||
            in_array(app('request')->method(), $methods[$action]);
    }
263211
public function getSuggestStatus($action)
    {
        if (is_null($this->getOrder())) {
            return;
        }

        $status = $this->getOrderPaymentStatusPaymentValid();
        if (is_null($status)) {
            $status = $this->getStatusByAction($action);
        }

        return $status;
    }
1026452
protected function hasBasicAuth($request) : bool
  {
    if ($request->headers->has('Authorization') && starts_with($request->header('Authorization'), 'Basic ')) {
      return true;
    }

    return false;
  }
21603
public function matchesAction($action)
    {
        $action = (array) $action;
        return $this->action === 'manage' || in_array($this->action, $action);
    }
307902
public function userAllowed($action)
    {
        if (user()->isAdmin()) {
            return true;
        }

        $this->_loadPermissions();
        $allowedRoles = $this->_permissions
            ->filter(function ($rule) use ($action) {
                return $rule->get('action') == $action;
            })
            ->extract('role_id')
            ->toArray();
        $intersect = array_intersect($allowedRoles, user()->get('role_ids'));

        return !empty($intersect);
    }
1372677
public function hasAction($controller, $action = null)
    {
        if ($action === null) {
            list($controller, $action) = explode('.', $controller);
        }
        return in_array("{$controller}.{$action}", $this->action_names);
    }
1314445
public function checkAction($actions)
    {
        if (!$this->action) {
            return false;
        }

        if (in_array($this->action, (array)$actions)) {
            return true;
        }

        return false;
    }
976380
protected function viaApi(string $action): bool
    {
        if (mb_strpos($action, 'api.') === 0) {
            return true; // Saves time in many cases.
        }
        return mb_strpos($action, 'api-v') === 0 && preg_match('/^api\-v[0-9]+[0-9.]*\./u', $action);
    }
838829
public function canExecute($action)
    {
        if (
            $this->isOwnable() &&
            $this->actor &&
            $this->actor->authorize('access') === false
            ) {
            return false;
        }

        return parent::canExecute($action);
    }
1237287
public static function isMethod($action) {
        switch (strtoupper($action)) {
        case 'GET':
            return $_SERVER['REQUEST_METHOD'] == 'GET';
        case 'POST':
            return $_SERVER['REQUEST_METHOD'] == 'POST';
        case 'DELETE':
            return $_SERVER['REQUEST_METHOD'] == 'DELETE'
            ?: (isset($_POST['_method']) && $_POST['_method'] == 'DELETE');
        case 'PUT':
            return $_SERVER['REQUEST_METHOD'] == 'PUT'
            ?: (isset($_POST['_method']) && $_POST['_method'] == 'PUT');
        case 'AJAX':
            return static::isAjax();
        case 'wechat':
            return static::isWeChat();
        case 'mobile':
            return static::isMobile();
        }
    }