You are here

function mo_auth_checkpassword in Google Authenticator / 2 Factor Authentication - 2FA 7

1 string reference to 'mo_auth_checkpassword'
mo_auth_menu in ./mo_auth.module
Implements hook_menu().

File

./mo_auth.module, line 704
Module file for miniOrange 2FA Module.

Code

function mo_auth_checkpassword() {
  global $user;
  if (isset($_POST['password'])) {

    // either you are admin or you are using correct uid
    $account = user_load($_POST['ajaxCallId']);
    if ($account->uid == 0 || $account->uid != $user->uid && !(in_array('administrator', $user->roles) || in_array('admin', $user->roles))) {
      echo json_encode(array(
        "isUnique" => FALSE,
      ));
    }
    $plainPassword = $_POST['password'];
    $passwordValidator = new MoAuthPasswordValidator($plainPassword, $account);
    echo json_encode(array(
      "isUnique" => $passwordValidator
        ->isPasswordUnique(),
    ));
  }
  else {
    echo json_encode(array(
      "isUnique" => FALSE,
    ));
  }
  exit;
}