function mo2f_pass2login_otp_verification($user, $mo2f_second_factor) { if ($mo2f_second_factor == 'SOFT TOKEN') { $_SESSION['mo2f-login-message'] = 'Please enter the one time passcode shown in the <b>miniOrange Authenticator</b> app.'; $_SESSION['mo_2factor_login_status'] = 'MO_2_FACTOR_CHALLENGE_SOFT_TOKEN'; } else { if ($mo2f_second_factor == 'GOOGLE AUTHENTICATOR') { $_SESSION['mo2f-login-message'] = 'Please enter the one time passcode shown in the <b>Google Authenticator</b> app.'; $_SESSION['mo_2factor_login_status'] = 'MO_2_FACTOR_CHALLENGE_GOOGLE_AUTHENTICATION'; } else { $challengeMobile = new Customer_Setup(); $content = $challengeMobile->send_otp_token(get_user_meta($user->ID, 'mo_2factor_map_id_with_email', true), $mo2f_second_factor, get_option('mo2f_customerKey'), get_option('mo2f_api_key')); $response = json_decode($content, true); if (json_last_error() == JSON_ERROR_NONE) { if ($response['status'] == 'SUCCESS') { $message = $mo2f_second_factor == 'SMS' ? 'The OTP has been sent to ' . MO2f_Utility::get_hidden_phone($response['phoneDelivery']['contact']) . '. Please enter the OTP you received to Validate.' : 'You will receive phone call on ' . MO2f_Utility::get_hidden_phone($response['phoneDelivery']['contact']) . ' with OTP. Please enter the OTP to Validate.'; $_SESSION['mo2f-login-message'] = $message; $_SESSION['mo2f-login-transactionId'] = $response['txId']; $_SESSION['mo_2factor_login_status'] = $mo2f_second_factor == 'SMS' ? 'MO_2_FACTOR_CHALLENGE_OTP_OVER_SMS' : 'MO_2_FACTOR_CHALLENGE_PHONE_VERIFICATION'; } else { $this->remove_current_activity(); $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: An error occured while processing your request. Please Try again.')); return $error; } } else { $this->remove_current_activity(); $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: An error occured while processing your request. Please Try again.')); return $error; } } } }