You are here

function MoAuthPasswordValidator::getRuleValue in Google Authenticator / 2 Factor Authentication - 2FA 7

1 call to MoAuthPasswordValidator::getRuleValue()
MoAuthPasswordValidator::passwordMustNotBeRules in classes/MoAuthPasswordValidator.php

File

classes/MoAuthPasswordValidator.php, line 86

Class

MoAuthPasswordValidator

Code

function getRuleValue($rule) {
  $ruleParts = explode("+", $rule);
  $cUser = user_load($this->user->uid);
  $labels = array();
  $value = "";
  foreach ($ruleParts as $rule) {
    if (strpos($rule, "field_") !== FALSE) {
      $label = str_replace("_", "", str_replace("field_", "", $rule));
    }
    else {
      $label = $rule;
    }
    $labels[] = $label;
    $ruleValue = isset($cUser->{$rule}) ? $cUser->{$rule} : FALSE;
    if ($ruleValue !== FALSE && isset($ruleValue['und'][0]['value'])) {
      $value = $value . strval($ruleValue['und'][0]['value']);
    }
  }
  $ruleName = "Password must not be same as ";
  if (count($labels) > 1) {
    $ruleName .= "concatenation of ";
  }
  $ruleName = $ruleName . implode(',', $labels);
  return array(
    $ruleName,
    strcasecmp($value, $this->plainPassword) === 0,
  );
}