public function miniorange_pass2login_redirect() { if (!session_id() || session_id() == '' || !isset($_SESSION)) { session_start(); } if (isset($_POST['mo2f_trust_device_confirm_nonce'])) { /*register device as rba profile */ $nonce = $_POST['mo2f_trust_device_confirm_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-trust-device-confirm-nonce')) { $this->remove_current_activity(); $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { try { $currentuser = $_SESSION['mo2f_current_user']; mo2f_register_profile(get_user_meta($currentuser->ID, 'mo_2factor_map_id_with_email', true), 'true', $_SESSION['mo2f_rba_status']); } catch (Exception $e) { echo $e->getMessage(); } $this->mo2fa_pass2login(); } } if (isset($_POST['mo2f_trust_device_cancel_nonce'])) { /*do not register device as rba profile */ $nonce = $_POST['mo2f_trust_device_cancel_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-trust-device-cancel-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $this->mo2fa_pass2login(); } } if (isset($_POST['miniorange_kba_nonce'])) { /*check kba validation*/ $nonce = $_POST['miniorange_kba_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-kba-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $currentuser = isset($_SESSION['mo2f_current_user']) ? $_SESSION['mo2f_current_user'] : null; if (isset($_SESSION['mo2f_current_user'])) { if (MO2f_Utility::mo2f_check_empty_or_null($_POST['mo2f_answer_1']) || MO2f_Utility::mo2f_check_empty_or_null($_POST['mo2f_answer_2'])) { return; } $otpToken = array(); $otpToken[0] = $_SESSION['mo_2_factor_kba_questions'][0]; $otpToken[1] = sanitize_text_field($_POST['mo2f_answer_1']); $otpToken[2] = $_SESSION['mo_2_factor_kba_questions'][1]; $otpToken[3] = sanitize_text_field($_POST['mo2f_answer_2']); $check_trust_device = sanitize_text_field($_POST['mo2f_trust_device']); $kba_validate = new Customer_Setup(); $kba_validate_response = json_decode($kba_validate->validate_otp_token('KBA', null, $_SESSION['mo2f-login-transactionId'], $otpToken, get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); if (strcasecmp($kba_validate_response['status'], 'SUCCESS') == 0) { if (get_option('mo2f_deviceid_enabled') && $check_trust_device == 'true') { try { mo2f_register_profile(get_user_meta($currentuser->ID, 'mo_2factor_map_id_with_email', true), 'true', $_SESSION['mo2f_rba_status']); } catch (Exception $e) { echo $e->getMessage(); } $this->mo2fa_pass2login(); } else { $this->mo2fa_pass2login(); } } else { $_SESSION['mo2f-login-message'] = 'The answers you have provided are incorrect.'; } } else { $this->remove_current_activity(); return new WP_Error('invalid_username', __('<strong>ERROR</strong>: Please try again..')); } } } if (isset($_POST['miniorange_mobile_validation_nonce'])) { /*check mobile validation */ $nonce = $_POST['miniorange_mobile_validation_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-mobile-validation-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $currentuser = $_SESSION['mo2f_current_user']; $checkMobileStatus = new Two_Factor_Setup(); $content = $checkMobileStatus->check_mobile_status($_SESSION['mo2f-login-transactionId']); $response = json_decode($content, true); if (json_last_error() == JSON_ERROR_NONE) { if ($response['status'] == 'SUCCESS') { if (get_option('mo2f_deviceid_enabled')) { $_SESSION['mo_2factor_login_status'] = 'MO_2_FACTOR_REMEMBER_TRUSTED_DEVICE'; } else { $this->mo2fa_pass2login(); } } else { $this->remove_current_activity(); return new WP_Error('invalid_username', __('<strong>ERROR</strong>: Please try again.')); } } else { $this->remove_current_activity(); return new WP_Error('invalid_username', __('<strong>ERROR</strong>: Please try again.')); } } } if (isset($_POST['miniorange_mobile_validation_failed_nonce'])) { /*Back to miniOrange Login Page if mobile validation failed and from back button of mobile challenge, soft token and default login*/ $nonce = $_POST['miniorange_mobile_validation_failed_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-mobile-validation-failed-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $this->remove_current_activity(); } } if (isset($_POST['miniorange_forgotphone'])) { /*Click on the link of forgotphone */ $nonce = $_POST['miniorange_forgotphone']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-forgotphone')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $customer = new Customer_Setup(); $id = $_SESSION['mo2f_current_user']->ID; $content = json_decode($customer->send_otp_token(get_user_meta($id, 'mo_2factor_map_id_with_email', true), 'EMAIL', get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); if (strcasecmp($content['status'], 'SUCCESS') == 0) { unset($_SESSION['mo2f-login-qrCode']); unset($_SESSION['mo2f-login-transactionId']); $_SESSION['mo2f-login-message'] = 'A one time passcode has been sent to <b>' . MO2f_Utility::mo2f_get_hiden_email(get_user_meta($id, 'mo_2factor_map_id_with_email', true)) . '</b>. Please enter the OTP to verify your identity.'; $_SESSION['mo2f-login-transactionId'] = $content['txId']; $_SESSION['mo_2factor_login_status'] = 'MO_2_FACTOR_CHALLENGE_OTP_OVER_EMAIL'; } else { $_SESSION['mo2f-login-message'] = 'Error:OTP over Email'; } } } if (isset($_POST['miniorange_inline_user_reg_nonce'])) { $nonce = $_POST['miniorange_inline_user_reg_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-inline-user-reg-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $email = ''; if (MO2f_Utility::mo2f_check_empty_or_null($_POST['mo_useremail'])) { $_SESSION['mo2f-login-message'] = 'Please enter email-id to register.'; return; } else { $email = sanitize_email($_POST['mo_useremail']); } if (!MO2f_Utility::check_if_email_is_already_registered($email)) { $currentUserId = $_SESSION['mo2f_current_user']->ID; update_user_meta($currentUserId, 'mo_2factor_user_email', $email); $enduser = new Two_Factor_Setup(); $check_user = json_decode($enduser->mo_check_user_already_exist($email), true); if (json_last_error() == JSON_ERROR_NONE) { if ($check_user['status'] == 'ERROR') { $_SESSION['mo2f-login-message'] = $check_user['message']; return; } else { if (strcasecmp($check_user['status'], 'USER_FOUND_UNDER_DIFFERENT_CUSTOMER') == 0) { $_SESSION['mo2f-login-message'] = 'The email you entered is already registered. Please register with another email to set up Two-Factor.'; return; } else { if (strcasecmp($check_user['status'], 'USER_FOUND') == 0 || strcasecmp($check_user['status'], 'USER_NOT_FOUND') == 0) { $enduser = new Customer_Setup(); $content = json_decode($enduser->send_otp_token($email, 'EMAIL', get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); if (strcasecmp($content['status'], 'SUCCESS') == 0) { $_SESSION['mo_2factor_login_status'] = 'MO_2_FACTOR_PROMPT_FOR_USER_REG_OTP'; $_SESSION['mo2f-login-message'] = 'An OTP has been sent to <b>' . $email . '</b>. Please enter the OTP below to verify your email. If you didn\'t get the email, please check your <b>SPAM</b> folder.'; update_user_meta($currentUserId, 'mo_2fa_verify_otp_create_account', $content['txId']); update_user_meta($currentUserId, 'mo_2factor_user_registration_status', 'MO_2_FACTOR_OTP_DELIVERED_SUCCESS'); } else { $_SESSION['mo_2factor_login_status'] = 'MO_2_FACTOR_PROMPT_FOR_USER_REG_OTP'; $_SESSION['mo2f-login-message'] = 'There was an error in sending OTP over email. Please click on Resend OTP to try again.'; update_user_meta($currentUserId, 'mo_2factor_user_registration_status', 'MO_2_FACTOR_OTP_DELIVERED_FAILURE'); } } } } } } else { $_SESSION['mo2f-login-message'] = 'The email is already used by other user. Please register with other email.'; } } } if (isset($_POST['miniorange_inline_two_factor_setup'])) { $nonce = $_POST['miniorange_inline_two_factor_setup']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-inline-setup-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $_SESSION['mo_2factor_login_status'] = 'MO_2_FACTOR_PROMPT_USER_FOR_2FA_METHODS'; unset($_SESSION['mo2f_google_auth']); $_SESSION['mo2f-login-message'] = ''; delete_user_meta($_SESSION['mo2f_current_user']->ID, 'mo2f_selected_2factor_method'); } } if (isset($_POST['miniorange_inline_resend_otp_nonce'])) { //resend otp during user inline registration $nonce = $_POST['miniorange_inline_resend_otp_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-inline-resend-otp-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $currentUserId = $_SESSION['mo2f_current_user']->ID; $userkey = ''; if (get_user_meta($currentUserId, 'mo2f_selected_2factor_method', true) == 'SMS') { $currentMethod = "OTP_OVER_SMS"; $userkey = $_SESSION['mo2f_phone']; $_SESSION['mo2f-login-message'] = 'The One Time Passcode has been sent to ' . $userkey . '. Please enter the one time passcode below to verify your number.'; } else { if (get_user_meta($currentUserId, 'mo2f_selected_2factor_method', true) == 'PHONE VERIFICATION') { $currentMethod = "PHONE_VERIFICATION"; $userkey = $_SESSION['mo2f_phone']; $_SESSION['mo2f-login-message'] = 'You will receive a phone call on this number ' . $userkey . '. Please enter the one time passcode below to verify your number.'; } else { $currentMethod = 'EMAIL'; $userkey = get_user_meta($currentUserId, 'mo_2factor_user_email', true); $_SESSION['mo2f-login-message'] = 'An OTP has been sent to <b>' . $userkey . '</b>. Please enter the OTP below to verify your email.'; } } $customer = new Customer_Setup(); $content = json_decode($customer->send_otp_token($userkey, $currentMethod, get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); if (strcasecmp($content['status'], 'SUCCESS') == 0) { update_user_meta($currentUserId, 'mo_2fa_verify_otp_create_account', $content['txId']); if ($currentMethod == 'EMAIL') { update_user_meta($currentUserId, 'mo_2factor_user_registration_status', 'MO_2_FACTOR_OTP_DELIVERED_SUCCESS'); $_SESSION['mo_2factor_login_status'] = 'MO_2_FACTOR_PROMPT_FOR_USER_REG_OTP'; } } else { $_SESSION['mo2f-login-message'] = 'There was an error in sending one time passcode. Please click on Resend OTP to try again.'; if ($currentMethod == 'EMAIL') { update_user_meta($currentUserId, 'mo_2factor_user_registration_status', 'MO_2_FACTOR_OTP_DELIVERED_FAILURE'); $_SESSION['mo_2factor_login_status'] = 'MO_2_FACTOR_PROMPT_FOR_USER_REG_OTP'; } } } } if (isset($_POST['mo2f_inline_ga_phone_type_nonce'])) { //select google phone type during user inline registration when google authenticator is selected $nonce = $_POST['mo2f_inline_ga_phone_type_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-inline-ga-phone-type-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $phone_type = $_POST['google_phone_type']; $current_user = $_SESSION['mo2f_current_user']; $google_auth = new Miniorange_Rba_Attributes(); $google_response = json_decode($google_auth->mo2f_google_auth_service(get_user_meta($current_user->ID, 'mo_2factor_map_id_with_email', true)), true); if (json_last_error() == JSON_ERROR_NONE) { if ($google_response['status'] == 'SUCCESS') { $mo2f_google_auth = array(); $mo2f_google_auth['ga_qrCode'] = $google_response['qrCodeData']; $mo2f_google_auth['ga_secret'] = $google_response['secret']; $mo2f_google_auth['ga_phone'] = $phone_type; $_SESSION['mo2f_google_auth'] = $mo2f_google_auth; $_SESSION['mo2f-login-message'] = ''; } else { $_SESSION['mo2f-login-message'] = 'Error occurred while registering the user for google authenticator. Please try again.'; } } else { $_SESSION['mo2f-login-message'] = 'Invalid request. Please try again.'; } } } if (isset($_POST['mo2f_inline_validate_ga_nonce'])) { $nonce = $_POST['mo2f_inline_validate_ga_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-inline-google-auth-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $otpToken = $_POST['google_auth_code']; $current_user = $_SESSION['mo2f_current_user']; $mo2f_google_auth = isset($_SESSION['mo2f_google_auth']) ? $_SESSION['mo2f_google_auth'] : null; $ga_secret = $mo2f_google_auth != null ? $mo2f_google_auth['ga_secret'] : null; if (MO2f_Utility::mo2f_check_number_length($otpToken)) { $email = get_user_meta($current_user->ID, 'mo_2factor_map_id_with_email', true); $google_auth = new Miniorange_Rba_Attributes(); $google_response = json_decode($google_auth->mo2f_validate_google_auth($email, $otpToken, $ga_secret), true); if (json_last_error() == JSON_ERROR_NONE) { if ($google_response['status'] == 'SUCCESS') { $enduser = new Two_Factor_Setup(); $response = json_decode($enduser->mo2f_update_userinfo($email, get_user_meta($current_user->ID, 'mo2f_selected_2factor_method', true), null, null, null), true); if (json_last_error() == JSON_ERROR_NONE) { if ($response['status'] == 'SUCCESS') { update_user_meta($current_user->ID, 'mo2f_google_authentication_status', true); update_user_meta($current_user->ID, 'mo_2factor_user_registration_status', 'MO_2_FACTOR_PLUGIN_SETTINGS'); $this->mo2fa_pass2login(); } else { $_SESSION['mo2f-login-message'] = 'An error occured while processing your request. Please Try again.'; } } else { $_SESSION['mo2f-login-message'] = 'An error occured while processing your request. Please Try again.'; } } else { $_SESSION['mo2f-login-message'] = 'Error occurred while validating the OTP. Please try again. Possible causes: <br />1. You have enter invalid OTP.<br />2. You App Time is not sync.Go to seetings and tap on Time correction for codes and tap on Sync now .'; } } else { $_SESSION['mo2f-login-message'] = 'Error occurred while validating the user. Please try again.'; } } else { $_SESSION['mo2f-login-message'] = 'Only digits are allowed. Please enter again.'; } } } if (isset($_POST['miniorange_inline_validate_user_otp_nonce'])) { $nonce = $_POST['miniorange_inline_validate_user_otp_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-inline-validate-user-otp-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $otp_token = ''; if (MO2f_Utility::mo2f_check_empty_or_null($_POST['otp_token'])) { $_SESSION['mo2f-login-message'] = 'All the fields are required. Please enter valid entries.'; return; } else { $otp_token = sanitize_text_field($_POST['otp_token']); } $id = $_SESSION['mo2f_current_user']->ID; if (!MO2f_Utility::check_if_email_is_already_registered(get_user_meta($id, 'mo_2factor_user_email', true))) { $customer = new Customer_Setup(); $transactionId = get_user_meta($id, 'mo_2fa_verify_otp_create_account', true); $content = json_decode($customer->validate_otp_token('EMAIL', null, $transactionId, $otp_token, get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); if ($content['status'] == 'ERROR') { $_SESSION['mo2f-login-message'] = $content['message']; delete_user_meta($id, 'mo_2fa_verify_otp_create_account'); } else { if (strcasecmp($content['status'], 'SUCCESS') == 0) { //OTP validated and generate QRCode $this->mo2f_register_user_inline(get_user_meta($id, 'mo_2factor_user_email', true)); delete_user_meta($id, 'mo_2fa_verify_otp_create_account'); } else { // OTP Validation failed. $_SESSION['mo2f-login-message'] = 'Invalid OTP. Please try again.'; update_user_meta($id, 'mo_2factor_user_registration_status', 'MO_2_FACTOR_OTP_DELIVERED_FAILURE'); } delete_user_meta($id, 'mo_2fa_verify_otp_create_account'); } } else { $_SESSION['mo2f-login-message'] = 'The email is already used by other user. Please register with other email by clicking on Back button.'; } } } if (isset($_POST['miniorange_inline_save_2factor_method_nonce'])) { $nonce = $_POST['miniorange_inline_save_2factor_method_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-inline-save-2factor-method-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $currentUserId = $_SESSION['mo2f_current_user']->ID; if (get_user_meta($currentUserId, 'mo_2factor_user_registration_with_miniorange', true) == 'SUCCESS') { update_user_meta($currentUserId, 'mo2f_selected_2factor_method', $_POST['mo2f_selected_2factor_method']); //status for second factor selected by user } else { $_SESSION['mo2f-login-message'] = 'Invalid request. Please register with miniOrange to configure 2 Factor plugin.'; } } } if (isset($_POST['miniorange_inline_verify_phone_nonce'])) { $nonce = $_POST['miniorange_inline_verify_phone_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-inline-verify-phone-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $phone = sanitize_text_field($_POST['verify_phone']); if (MO2f_Utility::mo2f_check_empty_or_null($phone)) { $_SESSION['mo2f-login-message'] = 'All the fields are required. Please enter valid entries.'; return; } $phone = str_replace(' ', '', $phone); $_SESSION['mo2f_phone'] = $phone; $current_user = $_SESSION['mo2f_current_user']->ID; $customer = new Customer_Setup(); if (get_user_meta($current_user, 'mo2f_selected_2factor_method', true) == 'SMS') { $currentMethod = "OTP_OVER_SMS"; } else { if (get_user_meta($current_user, 'mo2f_selected_2factor_method', true) == 'PHONE VERIFICATION') { $currentMethod = "PHONE_VERIFICATION"; } } $content = json_decode($customer->send_otp_token($phone, $currentMethod, get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); if (json_last_error() == JSON_ERROR_NONE) { /* Generate otp token */ if ($content['status'] == 'ERROR') { $_SESSION['mo2f-login-message'] = $response['message']; } else { if ($content['status'] == 'SUCCESS') { $_SESSION['mo2f_transactionId'] = $content['txId']; if (get_user_meta($current_user, 'mo2f_selected_2factor_method', true) == 'SMS') { $_SESSION['mo2f-login-message'] = 'The One Time Passcode has been sent to ' . $phone . '. Please enter the one time passcode below to verify your number.'; } else { if (get_user_meta($current_user, 'mo2f_selected_2factor_method', true) == 'PHONE VERIFICATION') { $_SESSION['mo2f-login-message'] = 'You will receive a phone call on this number ' . $phone . '. Please enter the one time passcode below to verify your number.'; } } } else { $_SESSION['mo2f-login-message'] = 'An error occured while processing your request. Please Try again.'; } } } else { $_SESSION['mo2f-login-message'] = 'Invalid request. Please try again'; } } } if (isset($_POST['miniorange_inline_validate_otp_nonce'])) { $nonce = $_POST['miniorange_inline_validate_otp_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-inline-validate-otp-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $otp_token = ''; if (MO2f_Utility::mo2f_check_empty_or_null($_POST['otp_token'])) { $_SESSION['mo2f-login-message'] = 'All the fields are required. Please enter valid entries.'; return; } else { $otp_token = sanitize_text_field($_POST['otp_token']); } $current_user = $_SESSION['mo2f_current_user']->ID; $customer = new Customer_Setup(); $content = json_decode($customer->validate_otp_token(get_user_meta($current_user, 'mo2f_selected_2factor_method', true), null, $_SESSION['mo2f_transactionId'], $otp_token, get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); if ($content['status'] == 'ERROR') { $_SESSION['mo2f-login-message'] = $content['message']; } else { if (strcasecmp($content['status'], 'SUCCESS') == 0) { //OTP validated if (get_user_meta($current_user, 'mo2f_user_phone', true) && strlen(get_user_meta($current_user, 'mo2f_user_phone', true)) >= 4) { if ($_SESSION['mo2f_phone'] != get_user_meta($current_user, 'mo2f_user_phone', true)) { update_user_meta($current_user, 'mo2f_mobile_registration_status', false); } } $email = get_user_meta($current_user, 'mo_2factor_map_id_with_email', true); $phone = $_SESSION['mo2f_phone']; $enduser = new Two_Factor_Setup(); $response = json_decode($enduser->mo2f_update_userinfo($email, get_user_meta($current_user, 'mo2f_selected_2factor_method', true), $phone, null, null), true); if (json_last_error() == JSON_ERROR_NONE) { if ($response['status'] == 'ERROR') { unset($_SESSION['mo2f_phone']); $_SESSION['mo2f-login-message'] = $response['message']; $this->mo_auth_show_error_message(); } else { if ($response['status'] == 'SUCCESS') { update_user_meta($current_user, 'mo2f_otp_registration_status', true); update_user_meta($current_user, 'mo_2factor_user_registration_status', 'MO_2_FACTOR_PLUGIN_SETTINGS'); update_user_meta($current_user, 'mo2f_user_phone', $_SESSION['mo2f_phone']); unset($_SESSION['mo2f_phone']); $this->mo2fa_pass2login(); } else { unset($_SESSION['mo2f_phone']); $_SESSION['mo2f-login-message'] = 'An error occured while processing your request. Please Try again.'; } } } else { unset($_SESSION['mo2f_phone']); $_SESSION['mo2f-login-message'] = 'Invalid request. Please try again'; } } else { // OTP Validation failed. $_SESSION['mo2f-login-message'] = 'Invalid OTP. Please try again.'; } } } } if (isset($_POST['miniorange_inline_show_qrcode_nonce'])) { $nonce = $_POST['miniorange_inline_show_qrcode_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-inline-show-qrcode-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $current_user = $_SESSION['mo2f_current_user']; if (get_user_meta($current_user->ID, 'mo_2factor_user_registration_status', true) == 'MO_2_FACTOR_INITIALIZE_TWO_FACTOR') { $email = get_user_meta($current_user->ID, 'mo_2factor_map_id_with_email', true); $this->mo2f_inline_get_qr_code_for_mobile($email, $current_user->ID); } else { $_SESSION['mo2f-login-message'] = 'Invalid request. Please register with miniOrange before configuring your mobile.'; } } } if (isset($_POST['mo_auth_inline_mobile_registration_complete_nonce'])) { $nonce = $_POST['mo_auth_inline_mobile_registration_complete_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-inline-mobile-registration-complete-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { unset($_SESSION['mo2f-login-qrCode']); unset($_SESSION['mo2f-login-transactionId']); unset($_SESSION['mo2f_show_qr_code']); $current_user = $_SESSION['mo2f_current_user']->ID; $email = get_user_meta($current_user, 'mo_2factor_map_id_with_email', true); $enduser = new Two_Factor_Setup(); $response = json_decode($enduser->mo2f_update_userinfo($email, get_user_meta($current_user, 'mo2f_selected_2factor_method', true), null, null, null), true); if (json_last_error() == JSON_ERROR_NONE) { /* Generate Qr code */ if ($response['status'] == 'ERROR') { $_SESSION['mo2f-login-message'] = $response['message']; } else { if ($response['status'] == 'SUCCESS') { update_user_meta($current_user, 'mo2f_mobile_registration_status', true); update_user_meta($current_user, 'mo_2factor_user_registration_status', 'MO_2_FACTOR_PLUGIN_SETTINGS'); $this->mo2fa_pass2login(); } else { $_SESSION['mo2f-login-message'] = 'An error occured while processing your request. Please Try again.'; } } } else { $_SESSION['mo2f-login-message'] = 'Invalid request. Please try again'; } } } if (isset($_POST['mo2f_inline_save_kba_nonce'])) { $nonce = $_POST['mo2f_inline_save_kba_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-inline-save-kba-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { if (MO2f_Utility::mo2f_check_empty_or_null($_POST['mo2f_kbaquestion_1']) || MO2f_Utility::mo2f_check_empty_or_null($_POST['mo2f_kba_ans1']) || MO2f_Utility::mo2f_check_empty_or_null($_POST['mo2f_kbaquestion_2']) || MO2f_Utility::mo2f_check_empty_or_null($_POST['mo2f_kba_ans2']) || MO2f_Utility::mo2f_check_empty_or_null($_POST['mo2f_kbaquestion_3']) || MO2f_Utility::mo2f_check_empty_or_null($_POST['mo2f_kba_ans3'])) { $_SESSION['mo2f-login-message'] = 'All the fields are required. Please enter valid entries.'; return; } $kba_q1 = $_POST['mo2f_kbaquestion_1']; $kba_a1 = sanitize_text_field($_POST['mo2f_kba_ans1']); $kba_q2 = $_POST['mo2f_kbaquestion_2']; $kba_a2 = sanitize_text_field($_POST['mo2f_kba_ans2']); $kba_q3 = sanitize_text_field($_POST['mo2f_kbaquestion_3']); $kba_a3 = sanitize_text_field($_POST['mo2f_kba_ans3']); if (strcasecmp($kba_q1, $kba_q2) == 0 || strcasecmp($kba_q2, $kba_q3) == 0 || strcasecmp($kba_q3, $kba_q1) == 0) { $_SESSION['mo2f-login-message'] = 'The questions you select must be unique.'; return; } $current_user = $_SESSION['mo2f_current_user']; $email = get_user_meta($current_user->ID, 'mo_2factor_map_id_with_email', true); $kba_registration = new Two_Factor_Setup(); $kba_reg_reponse = json_decode($kba_registration->register_kba_details($email, $kba_q1, $kba_a1, $kba_q2, $kba_a2, $kba_q3, $kba_a3), true); if (json_last_error() == JSON_ERROR_NONE) { if ($kba_reg_reponse['status'] == 'SUCCESS') { $enduser = new Two_Factor_Setup(); $response = json_decode($enduser->mo2f_update_userinfo($email, get_user_meta($current_user->ID, 'mo2f_selected_2factor_method', true), null, null, null), true); if (json_last_error() == JSON_ERROR_NONE) { /* Generate Qr code */ if ($response['status'] == 'ERROR') { $_SESSION['mo2f-login-message'] = $response['message']; } else { if ($response['status'] == 'SUCCESS') { update_user_meta($current_user->ID, 'mo2f_kba_registration_status', true); update_user_meta($current_user->ID, 'mo_2factor_user_registration_status', 'MO_2_FACTOR_PLUGIN_SETTINGS'); $this->mo2fa_pass2login(); } } } else { $_SESSION['mo2f-login-message'] = 'Error occured while saving your kba details. Please try again.'; } } else { $_SESSION['mo2f-login-message'] = 'Error occured while saving your kba details. Please try again.'; } } else { $_SESSION['mo2f-login-message'] = 'Error occured while saving your kba details. Please try again.'; } } } if (isset($_POST['mo2f_inline_email_setup'])) { $nonce = $_POST['mo2f_inline_email_setup']; if (!wp_verify_nonce($nonce, 'miniorange-2fa-inline-email-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $current_user = $_SESSION['mo2f_current_user']; update_user_meta($current_user->ID, 'mo_2factor_user_registration_status', 'MO_2_FACTOR_PLUGIN_SETTINGS'); update_user_meta($current_user->ID, 'mo2f_email_verification_status', true); $this->mo2fa_pass2login(); } } if (isset($_POST['miniorange_softtoken'])) { /*Click on the link of phone is offline */ $nonce = $_POST['miniorange_softtoken']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-softtoken')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { unset($_SESSION['mo2f-login-qrCode']); unset($_SESSION['mo2f-login-transactionId']); $_SESSION['mo2f-login-message'] = 'Please enter the one time passcode shown in the miniOrange authenticator app.'; $_SESSION['mo_2factor_login_status'] = 'MO_2_FACTOR_CHALLENGE_SOFT_TOKEN'; } } if (isset($_POST['miniorange_soft_token_nonce'])) { /*Validate Soft Token,OTP over SMS,OTP over EMAIL,Phone verification */ $nonce = $_POST['miniorange_soft_token_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-soft-token-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $softtoken = ''; if (MO2f_utility::mo2f_check_empty_or_null($_POST['mo2fa_softtoken'])) { $_SESSION['mo2f-login-message'] = 'Please enter OTP to proceed.'; return; } else { $softtoken = sanitize_text_field($_POST['mo2fa_softtoken']); if (!MO2f_utility::mo2f_check_number_length($softtoken)) { $_SESSION['mo2f-login-message'] = 'Invalid OTP. Only digits within range 4-8 are allowed. Please try again.'; return; } } $currentuser = isset($_SESSION['mo2f_current_user']) ? $_SESSION['mo2f_current_user'] : null; if (isset($_SESSION['mo2f_current_user'])) { $customer = new Customer_Setup(); $content = ''; if (isset($_SESSION['mo_2factor_login_status']) && $_SESSION['mo_2factor_login_status'] == 'MO_2_FACTOR_CHALLENGE_OTP_OVER_EMAIL') { $content = json_decode($customer->validate_otp_token('EMAIL', null, $_SESSION['mo2f-login-transactionId'], $softtoken, get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); } else { if (isset($_SESSION['mo_2factor_login_status']) && $_SESSION['mo_2factor_login_status'] == 'MO_2_FACTOR_CHALLENGE_OTP_OVER_SMS') { $content = json_decode($customer->validate_otp_token('SMS', null, $_SESSION['mo2f-login-transactionId'], $softtoken, get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); } else { if (isset($_SESSION['mo_2factor_login_status']) && $_SESSION['mo_2factor_login_status'] == 'MO_2_FACTOR_CHALLENGE_PHONE_VERIFICATION') { $content = json_decode($customer->validate_otp_token('PHONE VERIFICATION', null, $_SESSION['mo2f-login-transactionId'], $softtoken, get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); } else { if (isset($_SESSION['mo_2factor_login_status']) && $_SESSION['mo_2factor_login_status'] == 'MO_2_FACTOR_CHALLENGE_SOFT_TOKEN') { $content = json_decode($customer->validate_otp_token('SOFT TOKEN', get_user_meta($currentuser->ID, 'mo_2factor_map_id_with_email', true), null, $softtoken, get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); } else { if (isset($_SESSION['mo_2factor_login_status']) && $_SESSION['mo_2factor_login_status'] == 'MO_2_FACTOR_CHALLENGE_GOOGLE_AUTHENTICATION') { $content = json_decode($customer->validate_otp_token('GOOGLE AUTHENTICATOR', get_user_meta($currentuser->ID, 'mo_2factor_map_id_with_email', true), null, $softtoken, get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); } else { $this->remove_current_activity(); return new WP_Error('invalid_username', __('<strong>ERROR</strong>: Invalid Request. Please try again.')); } } } } } if (strcasecmp($content['status'], 'SUCCESS') == 0) { if (get_option('mo2f_deviceid_enabled')) { $_SESSION['mo_2factor_login_status'] = 'MO_2_FACTOR_REMEMBER_TRUSTED_DEVICE'; } else { $this->mo2fa_pass2login(); } } else { $message = $_SESSION['mo_2factor_login_status'] == 'MO_2_FACTOR_CHALLENGE_SOFT_TOKEN' ? 'Invalid OTP ...Possible causes <br />1. You mis-typed the OTP, find the OTP again and type it. <br /> 2. Your phone time is not in sync with miniOrange servers. <br /><b>How to sync?</b> In the app,tap on Settings icon and then press Sync button.' : 'Invalid OTP. Please try again'; $_SESSION['mo2f-login-message'] = $message; } } else { $this->remove_current_activity(); return new WP_Error('invalid_username', __('<strong>ERROR</strong>: Please try again..')); } } } if (isset($_POST['miniorange_inline_skip_registration_nonce'])) { /*Validate Soft Token,OTP over SMS,OTP over EMAIL,Phone verification */ $nonce = $_POST['miniorange_inline_skip_registration_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-inline-skip-registration-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $this->mo2fa_pass2login(); } } if (isset($_POST['miniorange_inline_goto_user_registration_nonce'])) { /*Validate Soft Token,OTP over SMS,OTP over EMAIL,Phone verification */ $nonce = $_POST['miniorange_inline_goto_user_registration_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-inline-goto-user-registration-nonce')) { $error = new WP_Error(); $error->add('empty_username', __('<strong>ERROR</strong>: Invalid Request.')); return $error; } else { $current_user = $_SESSION['mo2f_current_user']; delete_user_meta($current_user->ID, 'mo_2factor_user_email'); delete_user_meta($current_user->ID, 'mo_2fa_verify_otp_create_account'); delete_user_meta($current_user->ID, 'mo_2factor_user_registration_status'); $_SESSION['mo2f-login-message'] = ''; $_SESSION['mo_2factor_login_status'] = 'MO_2_FACTOR_PROMPT_FOR_USER_REGISTRATION'; } } }
public function my_login_redirect() { if (!session_id() || session_id() == '' || !isset($_SESSION)) { session_start(); } if (isset($_POST['miniorange_login_nonce'])) { $nonce = $_POST['miniorange_login_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-login-nonce')) { $_SESSION['mo2f-login-message'] = 'Invalid request'; $this->mo_auth_show_error_message(); } else { //validation and sanitization $username = ''; if (MO2f_Utility::mo2f_check_empty_or_null($_POST['mo2fa_username'])) { $_SESSION['mo2f-login-message'] = 'Please enter username to proceed'; $this->mo_auth_show_error_message(); return; } else { $username = sanitize_text_field($_POST['mo2fa_username']); } if (username_exists($username)) { /*if username exists in wp site */ $user = new WP_User($username); if (!session_id() || session_id() == '' || !isset($_SESSION)) { session_start(); } $_SESSION['mo2f_current_user'] = $user; $roles = $user->roles; $current_role = array_shift($roles); if (get_option('mo2fa_' . $current_role)) { if (!session_id() || session_id() == '' || !isset($_SESSION)) { session_start(); } if (get_user_meta($user->ID, 'mo_2factor_map_id_with_email', true) && get_user_meta($user->ID, 'mo_2factor_user_registration_status', true) == 'MO_2_FACTOR_PLUGIN_SETTINGS') { //if(MO2f_Utility::check_if_request_is_from_mobile_device($_SERVER['HTTP_USER_AGENT'])){ //$this->mo2f_login_kba_verification($currentuser); //}else{ $mo2f_second_factor = mo2f_get_user_2ndfactor($user); if ($mo2f_second_factor == 'MOBILE AUTHENTICATION') { $this->mo2f_login_mobile_verification($user); } else { if ($mo2f_second_factor == 'PUSH NOTIFICATIONS' || $mo2f_second_factor == 'OUT OF BAND EMAIL') { $this->mo2f_login_push_oobemail_verification($user, $mo2f_second_factor); } else { if ($mo2f_second_factor == 'SOFT TOKEN' || $mo2f_second_factor == 'SMS' || $mo2f_second_factor == 'PHONE VERIFICATION' || $mo2f_second_factor == 'GOOGLE AUTHENTICATOR') { $this->mo2f_login_otp_verification($user, $mo2f_second_factor); } else { if ($mo2f_second_factor == 'KBA') { $this->mo2f_login_kba_verification($user); } else { $this->remove_current_activity(); $_SESSION['mo2f-login-message'] = 'Please try again or contact your admin.'; $this->mo_auth_show_success_message(); } } } } //} } else { $_SESSION['mo2f-login-message'] = 'Please login into your account using password.'; $this->mo_auth_show_success_message(); $this->mo2f_redirectto_wp_login(); } } else { $_SESSION['mo2f-login-message'] = 'Please login into your account using password.'; $this->mo_auth_show_success_message(); $this->mo2f_redirectto_wp_login(); } } else { $this->remove_current_activity(); $_SESSION['mo2f-login-message'] = 'Invalid Username.'; $this->mo_auth_show_error_message(); } } } if (isset($_POST['miniorange_kba_nonce'])) { /*check kba validation*/ $nonce = $_POST['miniorange_kba_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-kba-nonce')) { $_SESSION['mo2f-login-message'] = 'Invalid request.'; $this->mo_auth_show_error_message(); } else { $currentuser = isset($_SESSION['mo2f_current_user']) ? $_SESSION['mo2f_current_user'] : null; if (isset($_SESSION['mo2f_current_user'])) { if (MO2f_Utility::mo2f_check_empty_or_null($_POST['mo2f_answer_1']) || MO2f_Utility::mo2f_check_empty_or_null($_POST['mo2f_answer_2'])) { return; } $otpToken = array(); $otpToken[0] = $_SESSION['mo_2_factor_kba_questions'][0]; $otpToken[1] = sanitize_text_field($_POST['mo2f_answer_1']); $otpToken[2] = $_SESSION['mo_2_factor_kba_questions'][1]; $otpToken[3] = sanitize_text_field($_POST['mo2f_answer_2']); $check_trust_device = sanitize_text_field($_POST['mo2f_trust_device']); $kba_validate = new Customer_Setup(); $kba_validate_response = json_decode($kba_validate->validate_otp_token('KBA', null, $_SESSION['mo2f-login-transactionId'], $otpToken, get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); if (username_exists($currentuser->user_login)) { // user is a member if (strcasecmp($kba_validate_response['status'], 'SUCCESS') == 0) { remove_filter('authenticate', 'wp_authenticate_username_password', 10, 3); add_filter('authenticate', array($this, 'mo2fa_login'), 10, 3); } else { $_SESSION['mo2f-login-message'] = 'The answers you have provided are incorrect.'; } } else { $this->remove_current_activity(); $_SESSION['mo2f-login-message'] = 'Invalid request.'; $this->mo_auth_show_error_message(); } } else { $this->remove_current_activity(); $_SESSION['mo2f-login-message'] = 'Invalid request.'; $this->mo_auth_show_error_message(); } } } if (isset($_POST['miniorange_mobile_validation_nonce'])) { /*check mobile validation */ $nonce = $_POST['miniorange_mobile_validation_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-mobile-validation-nonce')) { $_SESSION['mo2f-login-message'] = 'Invalid request.'; $this->mo_auth_show_error_message(); } else { $currentuser = $_SESSION['mo2f_current_user']; $username = $currentuser->user_login; if (username_exists($username)) { // user is a member $checkMobileStatus = new Two_Factor_Setup(); $content = $checkMobileStatus->check_mobile_status($_SESSION['mo2f-login-transactionId']); $response = json_decode($content, true); if (json_last_error() == JSON_ERROR_NONE) { if ($response['status'] == 'SUCCESS') { remove_filter('authenticate', 'wp_authenticate_username_password', 10, 3); add_filter('authenticate', array($this, 'mo2fa_login'), 10, 3); } else { $this->remove_current_activity(); $_SESSION['mo2f-login-message'] = 'Invalid request.'; $this->mo_auth_show_error_message(); } } else { $this->remove_current_activity(); $_SESSION['mo2f-login-message'] = 'Invalid request.'; $this->mo_auth_show_error_message(); } } else { $this->remove_current_activity(); $_SESSION['mo2f-login-message'] = 'Invalid request.'; $this->mo_auth_show_error_message(); } } } if (isset($_POST['miniorange_mobile_validation_failed_nonce'])) { /*Back to miniOrange Login Page if mobile validation failed and from back button of mobile challenge, soft token and default login*/ $nonce = $_POST['miniorange_mobile_validation_failed_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-mobile-validation-failed-nonce')) { $_SESSION['mo2f-login-message'] = 'Invalid request.'; $this->mo_auth_show_error_message(); } else { $this->remove_current_activity(); } } if (isset($_POST['miniorange_forgotphone'])) { /*Click on the link of forgotphone */ $nonce = $_POST['miniorange_forgotphone']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-forgotphone')) { $_SESSION['mo2f-login-message'] = 'Invalid request.'; $this->mo_auth_show_error_message(); } else { $customer = new Customer_Setup(); $id = $_SESSION['mo2f_current_user']->ID; $content = json_decode($customer->send_otp_token(get_user_meta($id, 'mo_2factor_map_id_with_email', true), 'EMAIL', get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); if (strcasecmp($content['status'], 'SUCCESS') == 0) { unset($_SESSION['mo2f-login-qrCode']); unset($_SESSION['mo2f-login-transactionId']); $_SESSION['mo2f-login-message'] = 'A one time passcode has been sent to <b>' . MO2f_Utility::mo2f_get_hiden_email(get_user_meta($id, 'mo_2factor_map_id_with_email', true)) . '</b>. Please enter the OTP to verify your identity.'; $_SESSION['mo2f-login-transactionId'] = $content['txId']; $_SESSION['mo_2factor_login_status'] = 'MO_2_FACTOR_CHALLENGE_OTP_OVER_EMAIL'; $this->mo_auth_show_success_message(); } else { $_SESSION['mo2f-login-message'] = 'Error:OTP over Email'; $this->mo_auth_show_success_message(); } } } if (isset($_POST['miniorange_softtoken'])) { /*Click on the link of phone is offline */ $nonce = $_POST['miniorange_softtoken']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-softtoken')) { $_SESSION['mo2f-login-message'] = 'Invalid request.'; $this->mo_auth_show_error_message(); } else { unset($_SESSION['mo2f-login-qrCode']); unset($_SESSION['mo2f-login-transactionId']); $_SESSION['mo2f-login-message'] = 'Please enter the one time passcode shown in the miniOrange authenticator app.'; $_SESSION['mo_2factor_login_status'] = 'MO_2_FACTOR_CHALLENGE_SOFT_TOKEN'; } } if (isset($_POST['miniorange_soft_token_nonce'])) { /*Validate Soft Token,OTP over SMS,OTP over EMAIL,Phone verification */ $nonce = $_POST['miniorange_soft_token_nonce']; if (!wp_verify_nonce($nonce, 'miniorange-2-factor-soft-token-nonce')) { $_SESSION['mo2f-login-message'] = 'Invalid request.'; $this->mo_auth_show_error_message(); } else { $softtoken = ''; if (MO2f_utility::mo2f_check_empty_or_null($_POST['mo2fa_softtoken'])) { $_SESSION['mo2f-login-message'] = 'Please enter OTP to proceed'; $this->mo_auth_show_error_message(); return; } else { $softtoken = sanitize_text_field($_POST['mo2fa_softtoken']); if (!MO2f_utility::mo2f_check_number_length($softtoken)) { $_SESSION['mo2f-login-message'] = 'Invalid OTP. Only digits within range 4-8 are allowed. Please try again.'; return; } } $currentuser = isset($_SESSION['mo2f_current_user']) ? $_SESSION['mo2f_current_user'] : null; if (isset($_SESSION['mo2f_current_user'])) { $customer = new Customer_Setup(); $content = ''; if (isset($_SESSION['mo_2factor_login_status']) && $_SESSION['mo_2factor_login_status'] == 'MO_2_FACTOR_CHALLENGE_OTP_OVER_EMAIL') { $content = json_decode($customer->validate_otp_token('EMAIL', null, $_SESSION['mo2f-login-transactionId'], $softtoken, get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); } else { if (isset($_SESSION['mo_2factor_login_status']) && $_SESSION['mo_2factor_login_status'] == 'MO_2_FACTOR_CHALLENGE_OTP_OVER_SMS') { $content = json_decode($customer->validate_otp_token('SMS', null, $_SESSION['mo2f-login-transactionId'], $softtoken, get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); } else { if (isset($_SESSION['mo_2factor_login_status']) && $_SESSION['mo_2factor_login_status'] == 'MO_2_FACTOR_CHALLENGE_PHONE_VERIFICATION') { $content = json_decode($customer->validate_otp_token('PHONE VERIFICATION', null, $_SESSION['mo2f-login-transactionId'], $softtoken, get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); } else { if (isset($_SESSION['mo_2factor_login_status']) && $_SESSION['mo_2factor_login_status'] == 'MO_2_FACTOR_CHALLENGE_SOFT_TOKEN') { $content = json_decode($customer->validate_otp_token('SOFT TOKEN', get_user_meta($currentuser->ID, 'mo_2factor_map_id_with_email', true), null, $softtoken, get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); } else { if (isset($_SESSION['mo_2factor_login_status']) && $_SESSION['mo_2factor_login_status'] == 'MO_2_FACTOR_CHALLENGE_GOOGLE_AUTHENTICATION') { $content = json_decode($customer->validate_otp_token('GOOGLE AUTHENTICATOR', get_user_meta($currentuser->ID, 'mo_2factor_map_id_with_email', true), null, $softtoken, get_option('mo2f_customerKey'), get_option('mo2f_api_key')), true); } else { $this->remove_current_activity(); $_SESSION['mo2f-login-message'] = 'Invalid request. Please try again.'; $this->mo_auth_show_error_message(); } } } } } if (username_exists($currentuser->user_login)) { // user is a member if (strcasecmp($content['status'], 'SUCCESS') == 0) { remove_filter('authenticate', 'wp_authenticate_username_password', 10, 3); add_filter('authenticate', array($this, 'mo2fa_login'), 10, 3); } else { $message = $_SESSION['mo_2factor_login_status'] == 'MO_2_FACTOR_CHALLENGE_SOFT_TOKEN' ? 'Invalid OTP ...Possible causes <br />1. You mis-typed the OTP, find the OTP again and type it. <br /> 2. Your phone time is not in sync with miniOrange servers. <br /><b>How to sync?</b> In the app,tap on Settings icon and then press Sync button.' : 'Invalid OTP. Please try again'; $_SESSION['mo2f-login-message'] = $message; $this->mo_auth_show_error_message(); } } else { $this->remove_current_activity(); $_SESSION['mo2f-login-message'] = 'Invalid request.'; $this->mo_auth_show_error_message(); } } else { $this->remove_current_activity(); $_SESSION['mo2f-login-message'] = 'Invalid request.'; $this->mo_auth_show_error_message(); } } } }