You are here

private function RestrictIpService::allowAccessByPermission in Restrict IP 8.2

Same name and namespace in other branches
  1. 8 src/Service/RestrictIpService.php \Drupal\restrict_ip\Service\RestrictIpService::allowAccessByPermission()
  2. 3.x src/Service/RestrictIpService.php \Drupal\restrict_ip\Service\RestrictIpService::allowAccessByPermission()

* Test to see if access should be granted based on

1 call to RestrictIpService::allowAccessByPermission()
RestrictIpService::userIsBlocked in src/Service/RestrictIpService.php
*

File

src/Service/RestrictIpService.php, line 289

Class

RestrictIpService

Namespace

Drupal\restrict_ip\Service

Code

private function allowAccessByPermission() {
  static $allow_access;
  if (is_null($allow_access)) {
    $allow_access = [];
  }
  if (!isset($allow_access[$this->currentPath])) {
    $allow_access[$this->currentPath] = FALSE;
    if ($this->config
      ->get('allow_role_bypass')) {
      $current_path = $this->currentPath;
      if ($this->currentUser
        ->hasPermission('bypass ip restriction') || in_array($current_path, array(
        '/user',
        '/user/login',
        '/user/password',
        '/user/logout',
        '/user/register',
      )) || strpos($current_path, '/user/reset/') === 0) {
        $allow_access[$this->currentPath] = TRUE;
      }
    }
  }
  return $allow_access[$this->currentPath];
}