You are here

function ga_login_test_form_submit in Google Authenticator login 6

File

./ga_login.module, line 116

Code

function ga_login_test_form_submit($form, $form_state) {
  $uid = $form_state['values']['uid'];
  $code = $form_state['values']['code'];
  $account = user_load($uid);
  module_load_include('php', 'ga_login', 'ga_login.class');
  $ga = new ga_loginGA(variable_get('ga_login_totp_skew', 10), variable_get('ga_login_hotp_skew', 10));
  $username = _ga_login_username($account);
  $keyok = $ga
    ->authenticateUser($username, $code);
  if ($keyok) {
    drupal_set_message('Authentication OK');
  }
  else {
    drupal_set_message('Authentication failed');
    drupal_set_message($ga
      ->getErrorText());
  }
}