You are here

private function RestrictIpService::allowAccessWhitelistCountry in Restrict IP 8.2

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

* Test to see if the current user is whitelisted based on their country

1 call to RestrictIpService::allowAccessWhitelistCountry()
RestrictIpService::testForBlock in src/Service/RestrictIpService.php
*

File

src/Service/RestrictIpService.php, line 401

Class

RestrictIpService

Namespace

Drupal\restrict_ip\Service

Code

private function allowAccessWhitelistCountry() {
  $allow_access = FALSE;
  if ($this->config
    ->get('country_white_black_list') == 1) {
    $country_code = $this
      ->ip2CountryGetCurrentUserCountry();
    if ($country_code) {
      $countries = explode(':', $this->config
        ->get('country_list'));
      return in_array(strtoupper($country_code), $countries);
    }
  }
  return FALSE;
}