You are here

public static function Securepages::matchCurrentUser in Secure Pages 8

Checks if the user is in a role that is always forced onto HTTPS.

Return value

int The number of roles set on the user that require HTTPS enforcing.

3 calls to Securepages::matchCurrentUser()
FormBuilder::buildFormAction in src/FormBuilder.php
Builds the $form['#action'].
Securepages::checkRedirect in src/Securepages.php
Checks the current request and see if we need to redirect.
SecurepagesSubscriber::checkResponseRedirection in src/EventSubscriber/SecurepagesSubscriber.php
Event handler for response processing. Alters redirects if needed.

File

src/Securepages.php, line 62
Contains \Drupal\securepages\Securepages.

Class

Securepages
Utility class for global functionality.

Namespace

Drupal\securepages

Code

public static function matchCurrentUser() {
  $account = \Drupal::currentUser();
  $config_roles = \Drupal::config('securepages.settings')
    ->get('roles');
  $account_roles = $account
    ->getRoles();
  return count(array_intersect($account_roles, $config_roles));
}