You are here

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

1 call to handle_page_otp_validate_submit()
mo_auth_inline_registration_submit in ./mo_auth_inline_registration.inc

File

./mo_auth_inline_registration.inc, line 765

Code

function handle_page_otp_validate_submit($form, &$form_state) {
  $form_state['rebuild'] = TRUE;
  $method = $form_state['storage']['page_three_values']['mo_auth_method'];
  $otp_code = $form['mo_auth_otpoversms_code']['#value'];
  $challenge_response = $form_state['storage']['page_four_values']['user_challenge_response'];
  $validate_response = validate_otp_for_user($challenge_response->txId, $otp_code);
  if ($validate_response->status == 'SUCCESS') {
    $form_state['storage']['page_five'] = TRUE;
    $form_state['storage']['page_otp_validate_values'] = $form_state['values'];
    return;
  }
  elseif ($validate_response->status == 'FAILED') {
    $error = $validate_response->message;
    form_set_error('invalid_otp', $error);
    $form_state['storage']['error_code'] = 'INVALID_OTP';
    $error_form = mo_auth_get_otp_over_sms_validate_form($form_state, FALSE, $error);
    $form_state['complete form']['mo_auth_otpoversms_code']['#prefix'] = $error_form['mo_auth_otpoversms_code']['#prefix'];
    $form_state["rebuild"] = TRUE;
    return;
  }
}