original_string: public function authorize(string $action, string $scope = null): bool
      {
          if (!$this->get('authenticated')) {
              return false;
          }
  
          if ($this->get('state', 'enabled') !== 'enabled') {
              return false;
          }
  
          if (null !== $scope) {
              $action = $scope . '.' . $action;
          }
  
          $config = Grav::instance()['config'];
          $authorized = false;
  
          //Check group access level
          $groups = (array)$this->get('groups');
          foreach ($groups as $group) {
              $permission = $config->get("groups.{$group}.access.{$action}");
              $authorized = Utils::isPositive($permission);
              if ($authorized === true) {
                  break;
              }
          }
  
          //Check user access level
          $access = $this->get('access');
          if ($access && Utils::getDotNotation($access, $action) !== null) {
              $permission = $this->get("access.{$action}");
              $authorized = Utils::isPositive($permission);
          }
  
          return $authorized;
      }
code: public function authorize(string $action, string $scope = null): bool
      {
          if (!$this->get('authenticated')) {
              return false;
          }
  
          if ($this->get('state', 'enabled') !== 'enabled') {
              return false;
          }
  
          if (null !== $scope) {
              $action = $scope . '.' . $action;
          }
  
          $config = Grav::instance()['config'];
          $authorized = false;
  
          //Check group access level
          $groups = (array)$this->get('groups');
          foreach ($groups as $group) {
              $permission = $config->get("groups.{$group}.access.{$action}");
              $authorized = Utils::isPositive($permission);
              if ($authorized === true) {
                  break;
              }
          }
  
          //Check user access level
          $access = $this->get('access');
          if ($access && Utils::getDotNotation($access, $action) !== null) {
              $permission = $this->get("access.{$action}");
              $authorized = Utils::isPositive($permission);
          }
  
          return $authorized;
      }
code_tokens: public function authorize ( string $ action , string $ scope = null ) : bool { if ( ! $ this -> get ( 'authenticated' ) ) { return false ; } if ( $ this -> get ( 'state' , 'enabled' ) !== 'enabled' ) { return false ; } if ( null !== $ scope ) { $ action = $ scope . '.' . $ action ; } $ config = Grav :: instance ( ) [ 'config' ] ; $ authorized = false ; //Check group access level $ groups = ( array ) $ this -> get ( 'groups' ) ; foreach ( $ groups as $ group ) { $ permission = $ config -> get ( "groups.{$group}.access.{$action}" ) ; $ authorized = Utils :: isPositive ( $ permission ) ; if ( $ authorized === true ) { break ; } } //Check user access level $ access = $ this -> get ( 'access' ) ; if ( $ access && Utils :: getDotNotation ( $ access , $ action ) !== null ) { $ permission = $ this -> get ( "access.{$action}" ) ; $ authorized = Utils :: isPositive ( $ permission ) ; } return $ authorized ; }
docstring: Checks user authorization to the action.
  
  @param  string $action
  @param  string|null $scope
  @return bool
docstring_tokens: Checks user authorization to the action .