You are here

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

1 string reference to 'mo_auth_forgot_phone'
mo_auth_build_form in ./authenticate_user.inc

File

./authenticate_user.inc, line 240
This is used to authenticate user during login.

Code

function mo_auth_forgot_phone($form, &$form_state) {
  $form_state['rebuild'] = TRUE;
  $uid = $form_state['uid'];
  $user = user_load($uid);
  $user_email = $user->miniorange_registered_email[LANGUAGE_NONE][0]['value'];
  $customer = new MiniorangeCustomerProfile();
  $miniorange_user = new MiniorangeUser($customer
    ->getCustomerID(), $user_email, NULL, NULL, 'KBA');
  $auth_api_handler = new AuthenticationAPIHandler($customer
    ->getCustomerID(), $customer
    ->getAPIKey());
  $response = $auth_api_handler
    ->challenge($miniorange_user);
  if ($response->status == 'SUCCESS') {
    $_SESSION['mo_auth']['mo_challenge_response'] = $response;
    $form_state['redirect'] = 'login/user/' . $user->uid . '/authenticate';
    $url = $form_state['redirect'];
    drupal_goto($url);
  }
  else {
    drupal_set_message(t('An error occured while processing your request. Please Try again.'), 'error');
    watchdog('miniorange_2fa', $response->message);
    drupal_goto('user');
  }
}