You are here

public static function MoAuthUtilities::check_roles_to_invoke_2fa in Google Authenticator / 2 Factor Authentication - 2FA 8.2

Same name and namespace in other branches
  1. 8 src/MoAuthUtilities.php \Drupal\miniorange_2fa\MoAuthUtilities::check_roles_to_invoke_2fa()
2 calls to MoAuthUtilities::check_roles_to_invoke_2fa()
MoAuthUtilities::invoke2fa_OR_inlineRegistration in src/MoAuthUtilities.php
MoAuthUtilities::isTFARequired in src/MoAuthUtilities.php

File

src/MoAuthUtilities.php, line 411
This file is part of miniOrange 2FA module.

Class

MoAuthUtilities

Namespace

Drupal\miniorange_2fa

Code

public static function check_roles_to_invoke_2fa($roles) {
  $variables_and_values = array(
    'mo_auth_enable_role_based_2fa',
    'mo_auth_use_only_2nd_factor',
    'mo_auth_role_based_2fa_roles',
  );
  $mo_db_values = MoAuthUtilities::miniOrange_set_get_configurations($variables_and_values, 'GET');
  if ($mo_db_values['mo_auth_enable_role_based_2fa'] !== TRUE || $mo_db_values['mo_auth_use_only_2nd_factor'] === TRUE) {
    return TRUE;
  }
  $return_value = FALSE;
  $selected_roles = (array) json_decode($mo_db_values['mo_auth_role_based_2fa_roles']);
  foreach ($selected_roles as $sysName => $displayName) {
    if (in_array($sysName, $roles, TRUE)) {
      $return_value = TRUE;
      break;
    }
  }
  return $return_value;
}