You are here

public static function MoAuthUtilities::check_domain_to_invoke_2fa in Google Authenticator / 2 Factor Authentication - 2FA 7

1 call to MoAuthUtilities::check_domain_to_invoke_2fa()
mo_auth_form_alter_submit in ./mo_auth.module

File

classes/Utilities.php, line 152
This file is part of miniOrange 2FA module.

Class

MoAuthUtilities
@file This file is part of miniOrange 2FA module.

Code

public static function check_domain_to_invoke_2fa($moUserEmail) {
  $moUserEmail = strtolower($moUserEmail);
  $mo_auth_enable_domain_based_2fa = variable_get('mo_auth_enable_domain_based_2fa');
  if ($mo_auth_enable_domain_based_2fa != TRUE) {
    return TRUE;
  }
  $return_value = FALSE;
  $selected_domains = explode(';', variable_get('mo_auth_two_factor_domain_based_2fa_domains'));
  $moUserDomain = substr(strrchr($moUserEmail, "@"), 1);
  if (in_array($moUserDomain, $selected_domains)) {
    $return_value = TRUE;
  }
  if ($return_value == TRUE) {
    $exceptionEmails = variable_get('mo_auth_2fa_domain_exception_emails', '');
    $exceptionEmailsArray = explode(";", $exceptionEmails);
    foreach ($exceptionEmailsArray as $key => $value) {
      if (strcasecmp($value, $moUserEmail) == 0) {
        $return_value = FALSE;
        break;
      }
    }
  }
  $whiteOrBlack = variable_get('mo_2fa_domains_are_white_or_black', 'black') == 'white' ? FALSE : TRUE;
  return $return_value == $whiteOrBlack;
}