public function can($type)
    {
        if (!in_array($type, [Auth::CAN_CREATE, Auth::CAN_DELETE, Auth::CAN_UPDATE, Auth::CAN_VIEW])) {
            throw new InvalidConfigException("Invalid type of permission check.");
        }

        $can = Yii::$app->auth->matchApi($this->userAuthClass()->identity->id, $this->id, $type);

        if (!$can) {
            throw new ForbiddenHttpException("User is unable to access the API due to insufficient permissions.");
        }

        return true;
    }