Google Authenticator – WordPress Two Factor Authentication (2FA) - Version 5.0.6

Version Description

  • Google Authenticator (2FA) : Bug Fix for existing customers facing Cache issue.
Download this release

Release Info

Developer cyberlord92
Plugin Icon 128x128 Google Authenticator – WordPress Two Factor Authentication (2FA)
Version 5.0.6
Comparing to
See all releases

Code changes from version 5.0.5 to 5.0.6

class-customer-setup.php CHANGED
@@ -73,7 +73,7 @@ class Customer_Setup {
73
 
74
 
75
  function create_customer() {
76
- global $dbQueries;
77
  if ( ! MO2f_Utility::is_curl_installed() ) {
78
  $message = 'Please enable curl extension. <a href="admin.php?page=miniOrange_2_factor_settings&amp;mo2f_tab=mo2f_help">Click here</a> for the steps to enable curl or check Help & Troubleshooting.';
79
 
@@ -85,7 +85,7 @@ class Customer_Setup {
85
  global $user;
86
  $user = wp_get_current_user();
87
  $this->email = get_option( 'mo2f_email' );
88
- $this->phone = $dbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
89
  $password = get_option( 'mo2f_password' );
90
  $company = get_option( 'mo2f_admin_company' ) != '' ? get_option( 'mo2f_admin_company' ) : $_SERVER['SERVER_NAME'];
91
  $firstName = get_option( 'mo2f_admin_first_name' );
@@ -290,9 +290,9 @@ class Customer_Setup {
290
  }
291
  curl_close( $ch );
292
 
293
- $currentTimeInMillis = round(microtime(true) * 1000);
294
 
295
- return empty($content) ? $currentTimeInMillis : $content;
296
  }
297
 
298
  function get_customer_transactions( $cKey, $apiKey ) {
73
 
74
 
75
  function create_customer() {
76
+ global $Mo2fdbQueries;
77
  if ( ! MO2f_Utility::is_curl_installed() ) {
78
  $message = 'Please enable curl extension. <a href="admin.php?page=miniOrange_2_factor_settings&amp;mo2f_tab=mo2f_help">Click here</a> for the steps to enable curl or check Help & Troubleshooting.';
79
 
85
  global $user;
86
  $user = wp_get_current_user();
87
  $this->email = get_option( 'mo2f_email' );
88
+ $this->phone = $Mo2fdbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
89
  $password = get_option( 'mo2f_password' );
90
  $company = get_option( 'mo2f_admin_company' ) != '' ? get_option( 'mo2f_admin_company' ) : $_SERVER['SERVER_NAME'];
91
  $firstName = get_option( 'mo2f_admin_first_name' );
290
  }
291
  curl_close( $ch );
292
 
293
+ $currentTimeInMillis = round( microtime( true ) * 1000 );
294
 
295
+ return empty( $content ) ? $currentTimeInMillis : $content;
296
  }
297
 
298
  function get_customer_transactions( $cKey, $apiKey ) {
class-miniorange-2-factor-login.php CHANGED
@@ -27,7 +27,7 @@ include_once dirname( __FILE__ ) . '/miniorange_2_factor_common_login.php';
27
  class Miniorange_Mobile_Login {
28
 
29
  function mo2fa_default_login( $user, $username, $password ) {
30
- global $dbQueries;
31
 
32
  $currentuser = wp_authenticate_username_password( $user, $username, $password );
33
  if ( is_wp_error( $currentuser ) ) {
@@ -42,8 +42,8 @@ class Miniorange_Mobile_Login {
42
 
43
  if ( $enabled ) {
44
 
45
- $mo2f_user_email = $dbQueries->get_user_detail( 'mo2f_user_email', $currentuser->ID );
46
- $mo2f_user_registration_status = $dbQueries->get_user_detail( 'mo_2factor_user_registration_status', $currentuser->ID );
47
 
48
  if ( $mo2f_user_email && $mo2f_user_registration_status == 'MO_2_FACTOR_PLUGIN_SETTINGS' ) { //checking if user has configured any 2nd factor method
49
  $_SESSION['mo2f-login-message'] = '<strong>' . mo2f_lt( 'ERROR' ) . '</strong>: ' . mo2f_lt( 'Login with password is disabled for you. Please Login using your phone.' );
@@ -148,8 +148,8 @@ class Miniorange_Mobile_Login {
148
  }
149
 
150
  function mo_2_factor_hide_login() {
151
- wp_register_style( 'hide-login', plugins_url( 'includes/css/hide-login.css?version=5.0.5', __FILE__ ) );
152
- wp_register_style( 'bootstrap', plugins_url( 'includes/css/bootstrap.min.css?version=5.0.5', __FILE__ ) );
153
 
154
  wp_enqueue_style( 'hide-login' );
155
  wp_enqueue_style( 'bootstrap' );
@@ -211,7 +211,7 @@ class Miniorange_Mobile_Login {
211
  }
212
 
213
  function mo_2_factor_show_login_with_password_when_phonelogin_enabled() {
214
- wp_register_style( 'show-login', plugins_url( 'includes/css/show-login.css?version=5.0.5', __FILE__ ) );
215
  wp_enqueue_style( 'show-login' );
216
  }
217
 
@@ -233,9 +233,9 @@ class Miniorange_Mobile_Login {
233
 
234
  function mo_2_factor_show_login() {
235
  if ( get_option( 'mo2f_enable_login_with_2nd_factor' ) ) {
236
- wp_register_style( 'show-login', plugins_url( 'includes/css/hide-login-form.css?version=5.0.5', __FILE__ ) );
237
  } else {
238
- wp_register_style( 'show-login', plugins_url( 'includes/css/show-login.css?version=5.0.5', __FILE__ ) );
239
  }
240
  wp_enqueue_style( 'show-login' );
241
  }
27
  class Miniorange_Mobile_Login {
28
 
29
  function mo2fa_default_login( $user, $username, $password ) {
30
+ global $Mo2fdbQueries;
31
 
32
  $currentuser = wp_authenticate_username_password( $user, $username, $password );
33
  if ( is_wp_error( $currentuser ) ) {
42
 
43
  if ( $enabled ) {
44
 
45
+ $mo2f_user_email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $currentuser->ID );
46
+ $mo2f_user_registration_status = $Mo2fdbQueries->get_user_detail( 'mo_2factor_user_registration_status', $currentuser->ID );
47
 
48
  if ( $mo2f_user_email && $mo2f_user_registration_status == 'MO_2_FACTOR_PLUGIN_SETTINGS' ) { //checking if user has configured any 2nd factor method
49
  $_SESSION['mo2f-login-message'] = '<strong>' . mo2f_lt( 'ERROR' ) . '</strong>: ' . mo2f_lt( 'Login with password is disabled for you. Please Login using your phone.' );
148
  }
149
 
150
  function mo_2_factor_hide_login() {
151
+ wp_register_style( 'hide-login', plugins_url( 'includes/css/hide-login.css?version=5.0.6', __FILE__ ) );
152
+ wp_register_style( 'bootstrap', plugins_url( 'includes/css/bootstrap.min.css?version=5.0.6', __FILE__ ) );
153
 
154
  wp_enqueue_style( 'hide-login' );
155
  wp_enqueue_style( 'bootstrap' );
211
  }
212
 
213
  function mo_2_factor_show_login_with_password_when_phonelogin_enabled() {
214
+ wp_register_style( 'show-login', plugins_url( 'includes/css/show-login.css?version=5.0.6', __FILE__ ) );
215
  wp_enqueue_style( 'show-login' );
216
  }
217
 
233
 
234
  function mo_2_factor_show_login() {
235
  if ( get_option( 'mo2f_enable_login_with_2nd_factor' ) ) {
236
+ wp_register_style( 'show-login', plugins_url( 'includes/css/hide-login-form.css?version=5.0.6', __FILE__ ) );
237
  } else {
238
+ wp_register_style( 'show-login', plugins_url( 'includes/css/show-login.css?version=5.0.6', __FILE__ ) );
239
  }
240
  wp_enqueue_style( 'show-login' );
241
  }
class-miniorange-2-factor-pass2fa-login.php CHANGED
@@ -28,7 +28,7 @@ include_once dirname( __FILE__ ) . '/class-rba-attributes.php';
28
  class Miniorange_Password_2Factor_Login {
29
 
30
  public function miniorange_pass2login_redirect() {
31
- global $dbQueries;
32
  if ( ! get_option( 'mo2f_login_option' ) ) {
33
 
34
  if ( isset( $_POST['miniorange_login_nonce'] ) ) {
@@ -72,9 +72,9 @@ class Miniorange_Password_2Factor_Login {
72
 
73
  $current_roles = miniorange_get_user_role( $user );
74
  $enabled = miniorange_check_if_2fa_enabled_for_roles( $current_roles );
75
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
76
- $mo_2factor_user_registration_status = $dbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
77
- $kba_configuration_status = $dbQueries->get_user_detail( 'mo2f_SecurityQuestions_config_status', $user->ID );
78
  if ( $enabled ) {
79
  if ( $email && $mo_2factor_user_registration_status == 'MO_2_FACTOR_PLUGIN_SETTINGS' ) {
80
  if ( MO2f_Utility::check_if_request_is_from_mobile_device( $_SERVER['HTTP_USER_AGENT'] ) && $kba_configuration_status ) {
@@ -142,7 +142,7 @@ class Miniorange_Password_2Factor_Login {
142
  try {
143
 
144
  $user_id = MO2f_Utility::mo2f_retrieve_session_or_cookie_values( 'mo2f_current_user_id' );
145
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user_id );
146
 
147
  $mo2f_rba_status = MO2f_Utility::mo2f_retrieve_session_or_cookie_values( 'mo2f_rba_status' );
148
 
@@ -188,8 +188,8 @@ class Miniorange_Password_2Factor_Login {
188
  $redirect_to = isset( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : null;
189
  $user = unserialize( $_SESSION['mo2f_current_user'] );
190
  $user_id = MO2f_Utility::mo2f_retrieve_session_or_cookie_values( 'mo2f_current_user_id' );
191
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user_id );
192
- $kba_configuration_status = $dbQueries->get_user_detail( 'mo2f_SecurityQuestions_config_status', $user_id );
193
 
194
 
195
  if ( $forgot_phone_enable && $forgot_phone_email_enable && $second_factor == 'OTP OVER EMAIL' ) {
@@ -278,7 +278,7 @@ class Miniorange_Password_2Factor_Login {
278
 
279
  $kba_validate = new Customer_Setup();
280
  $kba_validate_response = json_decode( $kba_validate->validate_otp_token( 'KBA', null, $mo2f_login_transaction_id, $otpToken, get_option( 'mo2f_customerKey' ), get_option( 'mo2f_api_key' ) ), true );
281
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user_id );
282
 
283
  if ( strcasecmp( $kba_validate_response['status'], 'SUCCESS' ) == 0 ) {
284
  if ( get_option( 'mo2f_remember_device' ) && $check_trust_device == 'on' ) {
@@ -371,8 +371,8 @@ class Miniorange_Password_2Factor_Login {
371
  $this->miniorange_pass2login_start_session();
372
  $customer = new Customer_Setup();
373
  $user_id = MO2f_Utility::mo2f_retrieve_session_or_cookie_values( 'mo2f_current_user_id' );
374
- $user_email = $dbQueries->get_user_detail( 'mo2f_user_email', $user_id );
375
- $kba_configuration_status = $dbQueries->get_user_detail( 'mo2f_SecurityQuestions_config_status', $user_id );
376
 
377
  if ( $kba_configuration_status ) {
378
  $mo2fa_login_status = 'MO_2_FACTOR_CHALLENGE_KBA_AND_OTP_OVER_EMAIL';
@@ -457,7 +457,7 @@ class Miniorange_Password_2Factor_Login {
457
  }
458
 
459
  $user_id = MO2f_Utility::mo2f_retrieve_session_or_cookie_values( 'mo2f_current_user_id' );
460
- $user_email = $dbQueries->get_user_detail( 'mo2f_user_email', $user_id );
461
 
462
  if ( isset( $user_id ) ) {
463
 
@@ -585,8 +585,8 @@ class Miniorange_Password_2Factor_Login {
585
  }
586
 
587
  function mo2f_pass2login_kba_verification( $user_id, $redirect_to ) {
588
- global $dbQueries;
589
- $user_email = $dbQueries->get_user_detail( 'mo2f_user_email', $user_id );
590
 
591
  $challengeKba = new Customer_Setup();
592
  $content = $challengeKba->send_otp_token( $user_email, 'KBA', get_option( 'mo2f_customerKey' ), get_option( 'mo2f_api_key' ) );
@@ -757,8 +757,8 @@ class Miniorange_Password_2Factor_Login {
757
  }
758
 
759
  function mo2f_pass2login_mobile_verification( $user, $redirect_to ) {
760
- global $dbQueries;
761
- $user_email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
762
 
763
  $useragent = $_SERVER['HTTP_USER_AGENT'];
764
  if ( MO2f_Utility::check_if_request_is_from_mobile_device( $useragent ) ) {
@@ -806,8 +806,8 @@ class Miniorange_Password_2Factor_Login {
806
  }
807
 
808
  function mo2f_pass2login_push_oobemail_verification( $user, $mo2f_second_factor, $redirect_to ) {
809
- global $dbQueries;
810
- $user_email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
811
 
812
  $challengeMobile = new Customer_Setup();
813
  $content = $challengeMobile->send_otp_token( $user_email, $mo2f_second_factor, get_option( 'mo2f_customerKey' ), get_option( 'mo2f_api_key' ) );
@@ -841,9 +841,9 @@ class Miniorange_Password_2Factor_Login {
841
  }
842
 
843
  function mo2f_pass2login_otp_verification( $user, $mo2f_second_factor, $redirect_to ) {
844
- global $dbQueries;
845
  $mo2f_external_app_type = get_user_meta( $user->ID, 'mo2f_external_app_type', true );
846
- $mo2f_user_phone = $dbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
847
 
848
  if ( $mo2f_second_factor == 'SOFT TOKEN' ) {
849
  $mo2fa_login_message = 'Please enter the one time passcode shown in the miniOrange<b> Authenticator</b> app.';
@@ -911,7 +911,7 @@ class Miniorange_Password_2Factor_Login {
911
  }
912
 
913
  function miniorange_initiate_2nd_factor( $currentuser, $attributes = null, $redirect_to = null ) {
914
- global $dbQueries;
915
 
916
  $this->miniorange_pass2login_start_session();
917
  $_SESSION['mo2f_current_user_id'] = $currentuser->ID;
@@ -925,13 +925,13 @@ class Miniorange_Password_2Factor_Login {
925
  $is_2fa_enabled_for_users = get_option( 'mo2f_enable_2fa_for_users' );
926
  $is_2fa_enabled_by_users = get_option( 'mo2f_enable_2fa' );
927
 
928
- //$enabled_2fa_byusers = $dbQueries->get_user_detail( 'mo2f_2factor_enable_2fa_byusers', $currentuser->ID );
929
  //if ( $enabled_2fa_byusers ) {
930
-
931
- if ( $is_customer_admin || ( ! $is_customer_admin && $is_2fa_enabled_for_users && $is_2fa_enabled_by_users ) ) {
932
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $currentuser->ID );
933
- $mo_2factor_user_registration_status = $dbQueries->get_user_detail( 'mo_2factor_user_registration_status', $currentuser->ID );
934
- $kba_configuration_status = $dbQueries->get_user_detail( 'mo2f_SecurityQuestions_config_status', $currentuser->ID );
935
  if ( $email && $mo_2factor_user_registration_status == 'MO_2_FACTOR_PLUGIN_SETTINGS' ) { //checking if user has configured any 2nd factor method
936
  try {
937
  $mo2f_rba_status = mo2f_collect_attributes( $email, stripslashes( $attributes ) ); // Rba flow
28
  class Miniorange_Password_2Factor_Login {
29
 
30
  public function miniorange_pass2login_redirect() {
31
+ global $Mo2fdbQueries;
32
  if ( ! get_option( 'mo2f_login_option' ) ) {
33
 
34
  if ( isset( $_POST['miniorange_login_nonce'] ) ) {
72
 
73
  $current_roles = miniorange_get_user_role( $user );
74
  $enabled = miniorange_check_if_2fa_enabled_for_roles( $current_roles );
75
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
76
+ $mo_2factor_user_registration_status = $Mo2fdbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
77
+ $kba_configuration_status = $Mo2fdbQueries->get_user_detail( 'mo2f_SecurityQuestions_config_status', $user->ID );
78
  if ( $enabled ) {
79
  if ( $email && $mo_2factor_user_registration_status == 'MO_2_FACTOR_PLUGIN_SETTINGS' ) {
80
  if ( MO2f_Utility::check_if_request_is_from_mobile_device( $_SERVER['HTTP_USER_AGENT'] ) && $kba_configuration_status ) {
142
  try {
143
 
144
  $user_id = MO2f_Utility::mo2f_retrieve_session_or_cookie_values( 'mo2f_current_user_id' );
145
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user_id );
146
 
147
  $mo2f_rba_status = MO2f_Utility::mo2f_retrieve_session_or_cookie_values( 'mo2f_rba_status' );
148
 
188
  $redirect_to = isset( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : null;
189
  $user = unserialize( $_SESSION['mo2f_current_user'] );
190
  $user_id = MO2f_Utility::mo2f_retrieve_session_or_cookie_values( 'mo2f_current_user_id' );
191
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user_id );
192
+ $kba_configuration_status = $Mo2fdbQueries->get_user_detail( 'mo2f_SecurityQuestions_config_status', $user_id );
193
 
194
 
195
  if ( $forgot_phone_enable && $forgot_phone_email_enable && $second_factor == 'OTP OVER EMAIL' ) {
278
 
279
  $kba_validate = new Customer_Setup();
280
  $kba_validate_response = json_decode( $kba_validate->validate_otp_token( 'KBA', null, $mo2f_login_transaction_id, $otpToken, get_option( 'mo2f_customerKey' ), get_option( 'mo2f_api_key' ) ), true );
281
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user_id );
282
 
283
  if ( strcasecmp( $kba_validate_response['status'], 'SUCCESS' ) == 0 ) {
284
  if ( get_option( 'mo2f_remember_device' ) && $check_trust_device == 'on' ) {
371
  $this->miniorange_pass2login_start_session();
372
  $customer = new Customer_Setup();
373
  $user_id = MO2f_Utility::mo2f_retrieve_session_or_cookie_values( 'mo2f_current_user_id' );
374
+ $user_email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user_id );
375
+ $kba_configuration_status = $Mo2fdbQueries->get_user_detail( 'mo2f_SecurityQuestions_config_status', $user_id );
376
 
377
  if ( $kba_configuration_status ) {
378
  $mo2fa_login_status = 'MO_2_FACTOR_CHALLENGE_KBA_AND_OTP_OVER_EMAIL';
457
  }
458
 
459
  $user_id = MO2f_Utility::mo2f_retrieve_session_or_cookie_values( 'mo2f_current_user_id' );
460
+ $user_email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user_id );
461
 
462
  if ( isset( $user_id ) ) {
463
 
585
  }
586
 
587
  function mo2f_pass2login_kba_verification( $user_id, $redirect_to ) {
588
+ global $Mo2fdbQueries;
589
+ $user_email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user_id );
590
 
591
  $challengeKba = new Customer_Setup();
592
  $content = $challengeKba->send_otp_token( $user_email, 'KBA', get_option( 'mo2f_customerKey' ), get_option( 'mo2f_api_key' ) );
757
  }
758
 
759
  function mo2f_pass2login_mobile_verification( $user, $redirect_to ) {
760
+ global $Mo2fdbQueries;
761
+ $user_email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
762
 
763
  $useragent = $_SERVER['HTTP_USER_AGENT'];
764
  if ( MO2f_Utility::check_if_request_is_from_mobile_device( $useragent ) ) {
806
  }
807
 
808
  function mo2f_pass2login_push_oobemail_verification( $user, $mo2f_second_factor, $redirect_to ) {
809
+ global $Mo2fdbQueries;
810
+ $user_email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
811
 
812
  $challengeMobile = new Customer_Setup();
813
  $content = $challengeMobile->send_otp_token( $user_email, $mo2f_second_factor, get_option( 'mo2f_customerKey' ), get_option( 'mo2f_api_key' ) );
841
  }
842
 
843
  function mo2f_pass2login_otp_verification( $user, $mo2f_second_factor, $redirect_to ) {
844
+ global $Mo2fdbQueries;
845
  $mo2f_external_app_type = get_user_meta( $user->ID, 'mo2f_external_app_type', true );
846
+ $mo2f_user_phone = $Mo2fdbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
847
 
848
  if ( $mo2f_second_factor == 'SOFT TOKEN' ) {
849
  $mo2fa_login_message = 'Please enter the one time passcode shown in the miniOrange<b> Authenticator</b> app.';
911
  }
912
 
913
  function miniorange_initiate_2nd_factor( $currentuser, $attributes = null, $redirect_to = null ) {
914
+ global $Mo2fdbQueries;
915
 
916
  $this->miniorange_pass2login_start_session();
917
  $_SESSION['mo2f_current_user_id'] = $currentuser->ID;
925
  $is_2fa_enabled_for_users = get_option( 'mo2f_enable_2fa_for_users' );
926
  $is_2fa_enabled_by_users = get_option( 'mo2f_enable_2fa' );
927
 
928
+ //$enabled_2fa_byusers = $Mo2fdbQueries->get_user_detail( 'mo2f_2factor_enable_2fa_byusers', $currentuser->ID );
929
  //if ( $enabled_2fa_byusers ) {
930
+
931
+ if ( $is_customer_admin || ( ! $is_customer_admin && $is_2fa_enabled_for_users && $is_2fa_enabled_by_users ) ) {
932
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $currentuser->ID );
933
+ $mo_2factor_user_registration_status = $Mo2fdbQueries->get_user_detail( 'mo_2factor_user_registration_status', $currentuser->ID );
934
+ $kba_configuration_status = $Mo2fdbQueries->get_user_detail( 'mo2f_SecurityQuestions_config_status', $currentuser->ID );
935
  if ( $email && $mo_2factor_user_registration_status == 'MO_2_FACTOR_PLUGIN_SETTINGS' ) { //checking if user has configured any 2nd factor method
936
  try {
937
  $mo2f_rba_status = mo2f_collect_attributes( $email, stripslashes( $attributes ) ); // Rba flow
class-miniorange-2-factor-user-registration.php CHANGED
@@ -30,7 +30,7 @@ class Miniorange_User_Register {
30
  }
31
 
32
  function plugin_settings_style() {
33
- wp_enqueue_style( 'mo_2_factor_admin_settings_style', plugins_url( 'includes/css/style_settings.css?version=5.0.5', __FILE__ ) );
34
  }
35
 
36
  function mo_auth_success_message() {
@@ -80,7 +80,7 @@ class Miniorange_User_Register {
80
 
81
  public function mo2f_register_user() {
82
  global $wpdb;
83
- global $dbQueries;
84
  global $user;
85
  $user = wp_get_current_user();
86
  if ( mo_2factor_is_curl_installed() == 0 ) { ?>
@@ -93,7 +93,7 @@ class Miniorange_User_Register {
93
 
94
 
95
  $mo2f_active_tab = isset( $_GET['mo2f_tab'] ) ? $_GET['mo2f_tab'] : '2factor_setup';
96
- $mo_2factor_user_registration_status = $dbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
97
 
98
  ?>
99
 
@@ -170,7 +170,7 @@ class Miniorange_User_Register {
170
 
171
  function miniorange_user_save_settings() {
172
  global $wpdb;
173
- global $dbQueries;
174
  global $user;
175
  $user = wp_get_current_user();
176
 
@@ -202,7 +202,7 @@ class Miniorange_User_Register {
202
  delete_user_meta( $user->ID, 'mo_2fa_verify_otp_create_account' );
203
  } else { // OTP Validation failed.
204
  update_option( 'mo2f_message', Mo2fConstants::langTranslate( "INVALID_OTP" ) );
205
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => 'MO_2_FACTOR_OTP_DELIVERED_FAILURE' ) );
206
  $this->mo_auth_show_error_message();
207
  }
208
  }
@@ -222,7 +222,7 @@ class Miniorange_User_Register {
222
  }
223
 
224
  function mo2f_create_user( $user, $email ) { //creating user in miniOrange of wordpress non-admin
225
- global $dbQueries;
226
  $email = strtolower( $email );
227
  $enduser = new Two_Factor_Setup();
228
  $check_user = json_decode( $enduser->mo_check_user_already_exist( $email ), true );
@@ -234,7 +234,7 @@ class Miniorange_User_Register {
234
  if ( strcasecmp( $check_user['status'], 'USER_FOUND' ) == 0 ) {
235
  delete_user_meta( $user->ID, 'user_email' );
236
 
237
- $dbQueries->update_user_details( $user->ID, array(
238
  'user_registration_with_miniorange' => 'SUCCESS',
239
  'mo2f_user_email' => $email,
240
  'mo_2factor_user_registration_status' => 'MO_2_FACTOR_INITIALIZE_TWO_FACTOR',
@@ -253,7 +253,7 @@ class Miniorange_User_Register {
253
  } else {
254
  if ( strcasecmp( $content['status'], 'SUCCESS' ) == 0 ) {
255
  delete_user_meta( $user->ID, 'user_email' );
256
- $dbQueries->update_user_details( $user->ID, array(
257
  'user_registration_with_miniorange' => 'SUCCESS',
258
  'mo2f_user_email' => $email,
259
  'mo_2factor_user_registration_status' => 'MO_2_FACTOR_INITIALIZE_TWO_FACTOR',
30
  }
31
 
32
  function plugin_settings_style() {
33
+ wp_enqueue_style( 'mo_2_factor_admin_settings_style', plugins_url( 'includes/css/style_settings.css?version=5.0.6', __FILE__ ) );
34
  }
35
 
36
  function mo_auth_success_message() {
80
 
81
  public function mo2f_register_user() {
82
  global $wpdb;
83
+ global $Mo2fdbQueries;
84
  global $user;
85
  $user = wp_get_current_user();
86
  if ( mo_2factor_is_curl_installed() == 0 ) { ?>
93
 
94
 
95
  $mo2f_active_tab = isset( $_GET['mo2f_tab'] ) ? $_GET['mo2f_tab'] : '2factor_setup';
96
+ $mo_2factor_user_registration_status = $Mo2fdbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
97
 
98
  ?>
99
 
170
 
171
  function miniorange_user_save_settings() {
172
  global $wpdb;
173
+ global $Mo2fdbQueries;
174
  global $user;
175
  $user = wp_get_current_user();
176
 
202
  delete_user_meta( $user->ID, 'mo_2fa_verify_otp_create_account' );
203
  } else { // OTP Validation failed.
204
  update_option( 'mo2f_message', Mo2fConstants::langTranslate( "INVALID_OTP" ) );
205
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => 'MO_2_FACTOR_OTP_DELIVERED_FAILURE' ) );
206
  $this->mo_auth_show_error_message();
207
  }
208
  }
222
  }
223
 
224
  function mo2f_create_user( $user, $email ) { //creating user in miniOrange of wordpress non-admin
225
+ global $Mo2fdbQueries;
226
  $email = strtolower( $email );
227
  $enduser = new Two_Factor_Setup();
228
  $check_user = json_decode( $enduser->mo_check_user_already_exist( $email ), true );
234
  if ( strcasecmp( $check_user['status'], 'USER_FOUND' ) == 0 ) {
235
  delete_user_meta( $user->ID, 'user_email' );
236
 
237
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
238
  'user_registration_with_miniorange' => 'SUCCESS',
239
  'mo2f_user_email' => $email,
240
  'mo_2factor_user_registration_status' => 'MO_2_FACTOR_INITIALIZE_TWO_FACTOR',
253
  } else {
254
  if ( strcasecmp( $content['status'], 'SUCCESS' ) == 0 ) {
255
  delete_user_meta( $user->ID, 'user_email' );
256
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
257
  'user_registration_with_miniorange' => 'SUCCESS',
258
  'mo2f_user_email' => $email,
259
  'mo_2factor_user_registration_status' => 'MO_2_FACTOR_INITIALIZE_TWO_FACTOR',
class-rba-attributes.php CHANGED
@@ -98,9 +98,9 @@ class Miniorange_Rba_Attributes {
98
  }
99
  curl_close( $ch );
100
 
101
- $currentTimeInMillis = round(microtime(true) * 1000);
102
 
103
- return empty($content) ? $currentTimeInMillis : $content;
104
  }
105
 
106
  function make_curl_call( $url, $fields, $http_header_array ) {
98
  }
99
  curl_close( $ch );
100
 
101
+ $currentTimeInMillis = round( microtime( true ) * 1000 );
102
 
103
+ return empty( $content ) ? $currentTimeInMillis : $content;
104
  }
105
 
106
  function make_curl_call( $url, $fields, $http_header_array ) {
class-two-factor-setup.php CHANGED
@@ -101,9 +101,9 @@ class Two_Factor_Setup {
101
  }
102
  curl_close( $ch );
103
 
104
- $currentTimeInMillis = round(microtime(true) * 1000);
105
 
106
- return empty($content) ? $currentTimeInMillis : $content;
107
  }
108
 
109
  function make_curl_call( $url, $fields, $http_header_array ) {
101
  }
102
  curl_close( $ch );
103
 
104
+ $currentTimeInMillis = round( microtime( true ) * 1000 );
105
 
106
+ return empty( $content ) ? $currentTimeInMillis : $content;
107
  }
108
 
109
  function make_curl_call( $url, $fields, $http_header_array ) {
class-utility.php CHANGED
@@ -75,10 +75,10 @@ class MO2f_Utility {
75
  }
76
 
77
  public static function check_if_email_is_already_registered( $email ) {
78
- global $dbQueries;
79
  $users = get_users( array() );
80
  foreach ( $users as $user ) {
81
- $user_email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
82
  if ( $user_email == $email ) {
83
  return true;
84
  }
75
  }
76
 
77
  public static function check_if_email_is_already_registered( $email ) {
78
+ global $Mo2fdbQueries;
79
  $users = get_users( array() );
80
  foreach ( $users as $user ) {
81
+ $user_email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
82
  if ( $user_email == $email ) {
83
  return true;
84
  }
database/database_functions.php CHANGED
@@ -68,8 +68,9 @@ class Mo2fDB {
68
  function get_user_detail( $column_name, $user_id ) {
69
  global $wpdb;
70
  $user_column_detail = $wpdb->get_results( "SELECT " . $column_name . " FROM " . $this->userDetailsTable . " WHERE user_id = " . $user_id . ";" );
71
- $value = empty( $user_column_detail ) ? '' : get_object_vars($user_column_detail[0]);
72
- return $value == '' ? '' : $value[ $column_name ];
 
73
  }
74
 
75
  function delete_user_details( $user_id ) {
@@ -82,6 +83,17 @@ class Mo2fDB {
82
  return;
83
  }
84
 
 
 
 
 
 
 
 
 
 
 
 
85
  function update_user_details( $user_id, $update ) {
86
  global $wpdb;
87
  $count = count( $update );
68
  function get_user_detail( $column_name, $user_id ) {
69
  global $wpdb;
70
  $user_column_detail = $wpdb->get_results( "SELECT " . $column_name . " FROM " . $this->userDetailsTable . " WHERE user_id = " . $user_id . ";" );
71
+ $value = empty( $user_column_detail ) ? '' : get_object_vars( $user_column_detail[0] );
72
+
73
+ return $value == '' ? '' : $value[ $column_name ];
74
  }
75
 
76
  function delete_user_details( $user_id ) {
83
  return;
84
  }
85
 
86
+ function check_if_user_column_exists($user_id){
87
+ global $wpdb;
88
+ $value = $wpdb->query(
89
+ "SELECT * FROM " . $this->userDetailsTable . "
90
+ WHERE user_id = " . $user_id
91
+ );
92
+
93
+ return $value;
94
+
95
+ }
96
+
97
  function update_user_details( $user_id, $update ) {
98
  global $wpdb;
99
  $count = count( $update );
includes/images/mo2fa_bug.png ADDED
Binary file
miniorange_2_factor_common_login.php CHANGED
@@ -139,9 +139,9 @@ function mo2f_collect_attributes( $email, $attributes ) {
139
  }
140
 
141
  function mo2f_get_user_2ndfactor( $user ) {
142
- global $dbQueries;
143
 
144
- $mo2f_user_email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
145
  $enduser = new Two_Factor_Setup();
146
  $userinfo = json_decode( $enduser->mo2f_get_userinfo( $mo2f_user_email ), true );
147
  if ( json_last_error() == JSON_ERROR_NONE ) {
@@ -336,9 +336,9 @@ function mo2f_get_kba_authentication_prompt( $login_message, $redirect_to ) {
336
  }
337
 
338
  function mo2f_get_push_notification_oobemail_prompt( $id, $login_status, $login_message, $redirect_to ) {
339
- global $dbQueries;
340
  $mo2f_enable_forgotphone = get_option( 'mo2f_enable_forgotphone' );
341
- $mo2f_KBA_config_status = $dbQueries->get_user_detail( 'mo2f_SecurityQuestions_config_status', $id );
342
  $mo2f_is_new_customer = get_option( 'mo2f_is_NC' );
343
  ?>
344
  <html>
@@ -818,10 +818,10 @@ function mo2f_customize_logo() { ?>
818
  function echo_js_css_files() {
819
  echo '<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>';
820
  echo '<script src="' . plugins_url( 'includes/js/bootstrap.min.js', __FILE__ ) . '" ></script>';
821
- echo '<link rel="stylesheet" type="text/css" href="' . plugins_url( 'includes/css/bootstrap.min.css?version=5.0.5', __FILE__ ) . '" />';
822
- echo '<link rel="stylesheet" type="text/css" href="' . plugins_url( 'includes/css/front_end_login.css?version=5.0.5', __FILE__ ) . '" />';
823
- echo '<link rel="stylesheet" type="text/css" href="' . plugins_url( 'includes/css/style_settings.css?version=5.0.5', __FILE__ ) . '" />';
824
- echo '<link rel="stylesheet" type="text/css" href="' . plugins_url( 'includes/css/hide-login.css?version=5.0.5', __FILE__ ) . '" />';
825
 
826
  if ( get_option( 'mo2f_personalization_ui' ) ) {
827
  echo '<link rel="stylesheet" type="text/css" href="' . plugins_url( 'includes/css/mo2f_login_popup_ui.css', __FILE__ ) . '" />';
139
  }
140
 
141
  function mo2f_get_user_2ndfactor( $user ) {
142
+ global $Mo2fdbQueries;
143
 
144
+ $mo2f_user_email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
145
  $enduser = new Two_Factor_Setup();
146
  $userinfo = json_decode( $enduser->mo2f_get_userinfo( $mo2f_user_email ), true );
147
  if ( json_last_error() == JSON_ERROR_NONE ) {
336
  }
337
 
338
  function mo2f_get_push_notification_oobemail_prompt( $id, $login_status, $login_message, $redirect_to ) {
339
+ global $Mo2fdbQueries;
340
  $mo2f_enable_forgotphone = get_option( 'mo2f_enable_forgotphone' );
341
+ $mo2f_KBA_config_status = $Mo2fdbQueries->get_user_detail( 'mo2f_SecurityQuestions_config_status', $id );
342
  $mo2f_is_new_customer = get_option( 'mo2f_is_NC' );
343
  ?>
344
  <html>
818
  function echo_js_css_files() {
819
  echo '<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>';
820
  echo '<script src="' . plugins_url( 'includes/js/bootstrap.min.js', __FILE__ ) . '" ></script>';
821
+ echo '<link rel="stylesheet" type="text/css" href="' . plugins_url( 'includes/css/bootstrap.min.css?version=5.0.6', __FILE__ ) . '" />';
822
+ echo '<link rel="stylesheet" type="text/css" href="' . plugins_url( 'includes/css/front_end_login.css?version=5.0.6', __FILE__ ) . '" />';
823
+ echo '<link rel="stylesheet" type="text/css" href="' . plugins_url( 'includes/css/style_settings.css?version=5.0.6', __FILE__ ) . '" />';
824
+ echo '<link rel="stylesheet" type="text/css" href="' . plugins_url( 'includes/css/hide-login.css?version=5.0.6', __FILE__ ) . '" />';
825
 
826
  if ( get_option( 'mo2f_personalization_ui' ) ) {
827
  echo '<link rel="stylesheet" type="text/css" href="' . plugins_url( 'includes/css/mo2f_login_popup_ui.css', __FILE__ ) . '" />';
miniorange_2_factor_configuration.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  function mo_2_factor_register( $user ) {
3
- global $dbQueries;
4
  if ( mo_2factor_is_curl_installed() == 0 ) { ?>
5
  <p style="color:red;">(<?php echo mo2f_lt( 'Warning:' ); ?> <a
6
  href="http://php.net/manual/en/curl.installation.php"
@@ -21,7 +21,7 @@ function mo_2_factor_register( $user ) {
21
 
22
 
23
  $mo2f_active_tab = isset( $_GET['mo2f_tab'] ) ? $_GET['mo2f_tab'] : '2factor_setup';
24
- $mo_2factor_user_registration_status = $dbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
25
  $is_customer_admin = current_user_can( 'manage_options' ) && get_option( 'mo2f_miniorange_admin' ) == $user->ID ? true : false;
26
  $is_customer_registered = get_option( 'mo_2factor_admin_registration_status' );
27
  $can_display_admin_features = ! $is_customer_registered || ( current_user_can( 'manage_options' ) && get_option( 'mo2f_miniorange_admin' ) == $user->ID ) ? true : false;
@@ -81,7 +81,7 @@ function mo_2_factor_register( $user ) {
81
  <?php
82
  /* to update the status of existing customers for adding their user registration status */
83
  if ( get_option( 'mo_2factor_admin_registration_status' ) == 'MO_2_FACTOR_CUSTOMER_REGISTERED_SUCCESS' && get_option( 'mo2f_miniorange_admin' ) == $user->ID ) {
84
- $dbQueries->update_user_details( $user->ID, array( 'user_registration_with_miniorange' => 'SUCCESS' ) );
85
  }
86
  /* ----------------------------------------- */
87
  $session_variables = array( 'mo2f_google_auth', 'mo2f_authy_keys', 'mo2f_mobile_support' );
@@ -158,8 +158,8 @@ function mo_2_factor_register( $user ) {
158
  }
159
 
160
  function mo2f_show_registration_page( $user ) {
161
- global $dbQueries;
162
- $phone = $dbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
163
  ?>
164
 
165
  <!--Register with miniOrange-->
@@ -248,8 +248,8 @@ function mo2f_show_registration_page( $user ) {
248
  }
249
 
250
  function mo2f_show_otp_validation_page( $user ) {
251
- global $dbQueries;
252
- $phone = $dbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
253
  ?>
254
  <!-- Enter otp -->
255
 
@@ -350,7 +350,7 @@ function mo2f_rba_description() {
350
  class="button button-primary button-large"
351
  style="float:right; margin-top:2%;"><?php echo __( 'Activate Plugin', 'miniorange-2-factor-authentication' ); ?></a>
352
  <?php } ?>
353
- <?php if ( !get_option( 'mo2f_rba_purchased' ) ) { ?> <a
354
  <a onclick="mo2f_addonform('wp_2fa_addon_rba')" id="mo2f_purchase_rba_addon"
355
  class="button button-primary button-large"
356
  style="margin-right:2%;margin-top:2%;float:right;"><?php echo __( 'Purchase', 'miniorange-2-factor-authentication' ); ?></a><?php } ?>
@@ -395,8 +395,8 @@ function mo2f_rba_description() {
395
  }
396
 
397
  function show_2_factor_addons( $current_user ) {
398
- global $dbQueries;
399
- $mo2f_user_email = $dbQueries->get_user_detail( 'mo2f_user_email', $current_user->ID );
400
  $mo2f_active_sub_tab = isset( $_GET['mo2f_sub_tab'] ) ? $_GET['mo2f_sub_tab'] : 'rba';
401
  ?>
402
 
@@ -596,10 +596,10 @@ function show_custom_content() {
596
  }
597
 
598
  function show_2_factor_login_settings( $user ) {
599
- global $dbQueries;
600
  $roles = get_editable_roles();
601
 
602
- $mo_2factor_user_registration_status = $dbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
603
  ?>
604
 
605
 
1
  <?php
2
  function mo_2_factor_register( $user ) {
3
+ global $Mo2fdbQueries;
4
  if ( mo_2factor_is_curl_installed() == 0 ) { ?>
5
  <p style="color:red;">(<?php echo mo2f_lt( 'Warning:' ); ?> <a
6
  href="http://php.net/manual/en/curl.installation.php"
21
 
22
 
23
  $mo2f_active_tab = isset( $_GET['mo2f_tab'] ) ? $_GET['mo2f_tab'] : '2factor_setup';
24
+ $mo_2factor_user_registration_status = $Mo2fdbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
25
  $is_customer_admin = current_user_can( 'manage_options' ) && get_option( 'mo2f_miniorange_admin' ) == $user->ID ? true : false;
26
  $is_customer_registered = get_option( 'mo_2factor_admin_registration_status' );
27
  $can_display_admin_features = ! $is_customer_registered || ( current_user_can( 'manage_options' ) && get_option( 'mo2f_miniorange_admin' ) == $user->ID ) ? true : false;
81
  <?php
82
  /* to update the status of existing customers for adding their user registration status */
83
  if ( get_option( 'mo_2factor_admin_registration_status' ) == 'MO_2_FACTOR_CUSTOMER_REGISTERED_SUCCESS' && get_option( 'mo2f_miniorange_admin' ) == $user->ID ) {
84
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'user_registration_with_miniorange' => 'SUCCESS' ) );
85
  }
86
  /* ----------------------------------------- */
87
  $session_variables = array( 'mo2f_google_auth', 'mo2f_authy_keys', 'mo2f_mobile_support' );
158
  }
159
 
160
  function mo2f_show_registration_page( $user ) {
161
+ global $Mo2fdbQueries;
162
+ $phone = $Mo2fdbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
163
  ?>
164
 
165
  <!--Register with miniOrange-->
248
  }
249
 
250
  function mo2f_show_otp_validation_page( $user ) {
251
+ global $Mo2fdbQueries;
252
+ $phone = $Mo2fdbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
253
  ?>
254
  <!-- Enter otp -->
255
 
350
  class="button button-primary button-large"
351
  style="float:right; margin-top:2%;"><?php echo __( 'Activate Plugin', 'miniorange-2-factor-authentication' ); ?></a>
352
  <?php } ?>
353
+ <?php if ( ! get_option( 'mo2f_rba_purchased' ) ) { ?> <a
354
  <a onclick="mo2f_addonform('wp_2fa_addon_rba')" id="mo2f_purchase_rba_addon"
355
  class="button button-primary button-large"
356
  style="margin-right:2%;margin-top:2%;float:right;"><?php echo __( 'Purchase', 'miniorange-2-factor-authentication' ); ?></a><?php } ?>
395
  }
396
 
397
  function show_2_factor_addons( $current_user ) {
398
+ global $Mo2fdbQueries;
399
+ $mo2f_user_email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $current_user->ID );
400
  $mo2f_active_sub_tab = isset( $_GET['mo2f_sub_tab'] ) ? $_GET['mo2f_sub_tab'] : 'rba';
401
  ?>
402
 
596
  }
597
 
598
  function show_2_factor_login_settings( $user ) {
599
+ global $Mo2fdbQueries;
600
  $roles = get_editable_roles();
601
 
602
+ $mo_2factor_user_registration_status = $Mo2fdbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
603
  ?>
604
 
605
 
miniorange_2_factor_mobile_configuration.php CHANGED
@@ -16,8 +16,8 @@ include dirname( __FILE__ ) . '/views/test_google_authy_authenticator';
16
 
17
 
18
  function mo2f_check_if_registered_with_miniorange( $user ) {
19
- global $dbQueries;
20
- $user_registration_status = $dbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
21
 
22
  if ( ! ( in_array( $user_registration_status, array(
23
  'MO_2_FACTOR_INITIALIZE_MOBILE_REGISTRATION',
@@ -32,42 +32,42 @@ function mo2f_check_if_registered_with_miniorange( $user ) {
32
  }
33
 
34
  function mo2f_update_and_sync_user_two_factor( $user_id, $userinfo ) {
35
- global $dbQueries;
36
  $mo2f_second_factor = isset( $userinfo['authType'] ) && ! empty( $userinfo['authType'] ) ? $userinfo['authType'] : 'NONE';
37
 
38
  if ( $mo2f_second_factor == 'OUT OF BAND EMAIL' ) {
39
- $dbQueries->update_user_details( $user_id, array( 'mo2f_EmailVerification_config_status' => true ) );
40
  } else if ( $mo2f_second_factor == 'SMS' ) {
41
  $phone_num = $userinfo['phone'];
42
- $dbQueries->update_user_details( $user_id, array( 'mo2f_OTPOverSMS_config_status' => true ) );
43
  $_SESSION['user_phone'] = $phone_num;
44
  } else if ( in_array( $mo2f_second_factor, array(
45
  'SOFT TOKEN',
46
  'MOBILE AUTHENTICATION',
47
  'PUSH NOTIFICATIONS'
48
  ) ) ) {
49
- $dbQueries->update_user_details( $user_id, array(
50
  'mo2f_miniOrangeSoftToken_config_status' => true,
51
  'mo2f_miniOrangeQRCodeAuthentication_config_status' => true,
52
  'mo2f_miniOrangePushNotification_config_status' => true
53
  ) );
54
  } else if ( $mo2f_second_factor == 'KBA' ) {
55
- $dbQueries->update_user_details( $user_id, array( 'mo2f_SecurityQuestions_config_status' => true ) );
56
  } else if ( $mo2f_second_factor == 'GOOGLE AUTHENTICATOR' ) {
57
  $app_type = get_user_meta( $user_id, 'mo2f_external_app_type', true );
58
 
59
  if ( $app_type == 'Google Authenticator' ) {
60
- $dbQueries->update_user_details( $user_id, array(
61
  'mo2f_GoogleAuthenticator_config_status' => true
62
  ) );
63
  update_user_meta( $user_id, 'mo2f_external_app_type', 'Google Authenticator' );
64
  } else if ( $app_type == 'Authy Authenticator' ) {
65
- $dbQueries->update_user_details( $user_id, array(
66
  'mo2f_AuthyAuthenticator_config_status' => true
67
  ) );
68
  update_user_meta( $user_id, 'mo2f_external_app_type', 'Authy Authenticator' );
69
  } else {
70
- $dbQueries->update_user_details( $user_id, array(
71
  'mo2f_GoogleAuthenticator_config_status' => true
72
  ) );
73
 
@@ -79,14 +79,14 @@ function mo2f_update_and_sync_user_two_factor( $user_id, $userinfo ) {
79
  }
80
 
81
  function mo2f_get_activated_second_factor( $user ) {
82
- global $dbQueries;
83
- $user_registration_status = $dbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
84
- $is_customer_registered = $dbQueries->get_user_detail( 'user_registration_with_miniorange', $user->ID ) == 'SUCCESS' ? true : false;
85
- $useremail = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
86
 
87
  if ( $user_registration_status == 'MO_2_FACTOR_SUCCESS' ) {
88
  //checking this option for existing users
89
- $dbQueries->update_user_details( $user->ID, array( 'mobile_registration_status' => true ) );
90
  $mo2f_second_factor = 'MOBILE AUTHENTICATION';
91
 
92
  return $mo2f_second_factor;
@@ -240,10 +240,10 @@ function mo2f_show_user_otp_validation_page() {
240
  }
241
 
242
  function mo2f_show_instruction_to_allusers( $user, $mo2f_second_factor ) {
243
- global $dbQueries;
244
 
245
- $user_registration_status = $dbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
246
- $user_email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
247
  if ( $mo2f_second_factor == 'GOOGLE AUTHENTICATOR' ) {
248
 
249
  $app_type = get_user_meta( $user->ID, 'mo2f_external_app_type', true );
@@ -321,7 +321,7 @@ function mo2f_show_instruction_to_allusers( $user, $mo2f_second_factor ) {
321
 
322
  </table>
323
  <br>
324
- <?php if ( get_option( 'mo2f_is_NC') && current_user_can( 'manage_options' ) && get_option( 'mo2f_miniorange_admin' ) == $user->ID ) { ?>
325
  <button type="button" class="button button-primary button-large" style="float:right;" data-toggle="modal"
326
  data-target="#deactivateAccount"><?php echo mo2f_lt( 'Deactivate plugin' ); ?></button>
327
 
@@ -462,13 +462,13 @@ function mo2f_show_2FA_test_screen( $user, $selected2FAmethod ) {
462
 
463
 
464
  function mo2f_select_2_factor_method( $user, $mo2f_second_factor ) {
465
- global $dbQueries;
466
 
467
- $user_registration_status = $dbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
468
 
469
  $is_customer_admin_registered = get_option( 'mo_2factor_admin_registration_status' );
470
- $configured_2FA_method = $dbQueries->get_user_detail( 'mo2f_configured_2FA_method', $user->ID );
471
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
472
  $is_2FA_configured = $configured_2FA_method == 'NONE' ? 0 : 1;
473
 
474
  $selectedMethod = $mo2f_second_factor;
@@ -488,7 +488,7 @@ function mo2f_select_2_factor_method( $user, $mo2f_second_factor ) {
488
  $selectedMethod = MO2f_Utility::mo2f_decode_2_factor( $mo2f_second_factor, "servertowpdb" );
489
  }
490
  if ( $selectedMethod !== 'NONE' ) {
491
- $dbQueries->update_user_details( $user->ID, array(
492
  'mo2f_configured_2FA_method' => $selectedMethod,
493
  'mo2f_' . str_replace( ' ', '', $selectedMethod ) . '_config_status' => true
494
  ) );
@@ -503,7 +503,7 @@ function mo2f_select_2_factor_method( $user, $mo2f_second_factor ) {
503
  $is_customer_admin = current_user_can( 'manage_options' ) && get_option( 'mo2f_miniorange_admin' ) == $user->ID;
504
  $can_display_admin_features = ! $is_customer_admin_registered || $is_customer_admin ? true : false;
505
 
506
- $is_customer_registered = $dbQueries->get_user_detail( 'user_registration_with_miniorange', $user->ID ) == 'SUCCESS' ? true : false;
507
  if ( get_user_meta( $user->ID, 'configure_2FA', true ) ) {
508
 
509
  $current_selected_method = get_user_meta( $user->ID, 'mo2f_2FA_method_to_configure', true ); ?>
@@ -539,7 +539,7 @@ function mo2f_select_2_factor_method( $user, $mo2f_second_factor ) {
539
  <input type="checkbox" id="mo2f_enable_2fa_for_users" name="mo2f_enable_2fa_for_users"
540
  value="1" <?php checked( get_option( 'mo2f_enable_2fa_for_users' ) == 1 );
541
 
542
- if ( $dbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID ) != 'MO_2_FACTOR_PLUGIN_SETTINGS' ) {
543
  echo 'disabled';
544
  } ?> onChange="this.form.submit()"/>
545
  <?php echo mo2f_lt( 'Enable 2-factor Authentication for Users' ); ?>
@@ -553,7 +553,7 @@ function mo2f_select_2_factor_method( $user, $mo2f_second_factor ) {
553
  <input type="checkbox" id="mo2f_enable_2fa" name="mo2f_enable_2fa"
554
  value="1" <?php checked( get_option( 'mo2f_enable_2fa' ) == 1 );
555
 
556
- if ( ! in_array( $dbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID ), array(
557
  'MO_2_FACTOR_PLUGIN_SETTINGS',
558
  'MO_2_FACTOR_INITIALIZE_TWO_FACTOR'
559
  ) ) ) {
@@ -731,7 +731,7 @@ function mo2f_select_2_factor_method( $user, $mo2f_second_factor ) {
731
  }
732
 
733
  function mo2f_create_2fa_form( $user, $category, $auth_methods ) {
734
- global $dbQueries;
735
  $all_two_factor_methods = array(
736
  "miniOrange QR Code Authentication",
737
  "miniOrange Soft Token",
@@ -763,7 +763,7 @@ function mo2f_create_2fa_form( $user, $category, $auth_methods ) {
763
  $two_factor_methods_EC = array_slice( $all_two_factor_methods, 0, 8 );
764
  $two_factor_methods_NC = array_slice( $all_two_factor_methods, 0, 5 );
765
 
766
- $is_customer_registered = $dbQueries->get_user_detail( 'user_registration_with_miniorange', $user->ID ) == 'SUCCESS' ? true : false;
767
 
768
  $is_NC = get_option( 'mo2f_is_NC' );
769
  $is_EC = ! $is_NC;
@@ -778,7 +778,7 @@ function mo2f_create_2fa_form( $user, $category, $auth_methods ) {
778
  for ( $j = 0; $j < count( $auth_methods[ $i ] ); $j ++ ) {
779
  $auth_method = $auth_methods[ $i ][ $j ];
780
  $auth_method_abr = str_replace( ' ', '', $auth_method );
781
- $configured_auth_method = $dbQueries->get_user_detail( 'mo2f_configured_2FA_method', $user->ID );
782
  $is_auth_method_selected = ( $configured_auth_method == $auth_method ? true : false );
783
 
784
  $is_auth_method_av = false;
@@ -806,7 +806,7 @@ function mo2f_create_2fa_form( $user, $category, $auth_methods ) {
806
  </div>';
807
 
808
  if ( $is_auth_method_av && $category == 'free_plan' ) {
809
- $is_auth_method_configured = $dbQueries->get_user_detail( 'mo2f_' . $auth_method_abr . '_config_status', $user->ID );
810
 
811
  $form .= '<div style="height:40px;width:100%;position: absolute;bottom: 0;background-color:';
812
  $form .= $is_auth_method_selected ? '#48b74b' : '#8daddc';
@@ -845,11 +845,11 @@ function mo2f_create_2fa_form( $user, $category, $auth_methods ) {
845
  }
846
 
847
  function show_2_factor_pricing_page( $user ) {
848
- global $dbQueries;
849
 
850
  $is_NC = get_option( 'mo2f_is_NC' );
851
 
852
- $is_customer_registered = $dbQueries->get_user_detail( 'user_registration_with_miniorange', $user->ID ) == 'SUCCESS' ? true : false;
853
 
854
  $mo2f_feature_set = array(
855
  "Authentication Methods",
16
 
17
 
18
  function mo2f_check_if_registered_with_miniorange( $user ) {
19
+ global $Mo2fdbQueries;
20
+ $user_registration_status = $Mo2fdbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
21
 
22
  if ( ! ( in_array( $user_registration_status, array(
23
  'MO_2_FACTOR_INITIALIZE_MOBILE_REGISTRATION',
32
  }
33
 
34
  function mo2f_update_and_sync_user_two_factor( $user_id, $userinfo ) {
35
+ global $Mo2fdbQueries;
36
  $mo2f_second_factor = isset( $userinfo['authType'] ) && ! empty( $userinfo['authType'] ) ? $userinfo['authType'] : 'NONE';
37
 
38
  if ( $mo2f_second_factor == 'OUT OF BAND EMAIL' ) {
39
+ $Mo2fdbQueries->update_user_details( $user_id, array( 'mo2f_EmailVerification_config_status' => true ) );
40
  } else if ( $mo2f_second_factor == 'SMS' ) {
41
  $phone_num = $userinfo['phone'];
42
+ $Mo2fdbQueries->update_user_details( $user_id, array( 'mo2f_OTPOverSMS_config_status' => true ) );
43
  $_SESSION['user_phone'] = $phone_num;
44
  } else if ( in_array( $mo2f_second_factor, array(
45
  'SOFT TOKEN',
46
  'MOBILE AUTHENTICATION',
47
  'PUSH NOTIFICATIONS'
48
  ) ) ) {
49
+ $Mo2fdbQueries->update_user_details( $user_id, array(
50
  'mo2f_miniOrangeSoftToken_config_status' => true,
51
  'mo2f_miniOrangeQRCodeAuthentication_config_status' => true,
52
  'mo2f_miniOrangePushNotification_config_status' => true
53
  ) );
54
  } else if ( $mo2f_second_factor == 'KBA' ) {
55
+ $Mo2fdbQueries->update_user_details( $user_id, array( 'mo2f_SecurityQuestions_config_status' => true ) );
56
  } else if ( $mo2f_second_factor == 'GOOGLE AUTHENTICATOR' ) {
57
  $app_type = get_user_meta( $user_id, 'mo2f_external_app_type', true );
58
 
59
  if ( $app_type == 'Google Authenticator' ) {
60
+ $Mo2fdbQueries->update_user_details( $user_id, array(
61
  'mo2f_GoogleAuthenticator_config_status' => true
62
  ) );
63
  update_user_meta( $user_id, 'mo2f_external_app_type', 'Google Authenticator' );
64
  } else if ( $app_type == 'Authy Authenticator' ) {
65
+ $Mo2fdbQueries->update_user_details( $user_id, array(
66
  'mo2f_AuthyAuthenticator_config_status' => true
67
  ) );
68
  update_user_meta( $user_id, 'mo2f_external_app_type', 'Authy Authenticator' );
69
  } else {
70
+ $Mo2fdbQueries->update_user_details( $user_id, array(
71
  'mo2f_GoogleAuthenticator_config_status' => true
72
  ) );
73
 
79
  }
80
 
81
  function mo2f_get_activated_second_factor( $user ) {
82
+ global $Mo2fdbQueries;
83
+ $user_registration_status = $Mo2fdbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
84
+ $is_customer_registered = $Mo2fdbQueries->get_user_detail( 'user_registration_with_miniorange', $user->ID ) == 'SUCCESS' ? true : false;
85
+ $useremail = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
86
 
87
  if ( $user_registration_status == 'MO_2_FACTOR_SUCCESS' ) {
88
  //checking this option for existing users
89
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mobile_registration_status' => true ) );
90
  $mo2f_second_factor = 'MOBILE AUTHENTICATION';
91
 
92
  return $mo2f_second_factor;
240
  }
241
 
242
  function mo2f_show_instruction_to_allusers( $user, $mo2f_second_factor ) {
243
+ global $Mo2fdbQueries;
244
 
245
+ $user_registration_status = $Mo2fdbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
246
+ $user_email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
247
  if ( $mo2f_second_factor == 'GOOGLE AUTHENTICATOR' ) {
248
 
249
  $app_type = get_user_meta( $user->ID, 'mo2f_external_app_type', true );
321
 
322
  </table>
323
  <br>
324
+ <?php if ( get_option( 'mo2f_is_NC' ) && current_user_can( 'manage_options' ) && get_option( 'mo2f_miniorange_admin' ) == $user->ID ) { ?>
325
  <button type="button" class="button button-primary button-large" style="float:right;" data-toggle="modal"
326
  data-target="#deactivateAccount"><?php echo mo2f_lt( 'Deactivate plugin' ); ?></button>
327
 
462
 
463
 
464
  function mo2f_select_2_factor_method( $user, $mo2f_second_factor ) {
465
+ global $Mo2fdbQueries;
466
 
467
+ $user_registration_status = $Mo2fdbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
468
 
469
  $is_customer_admin_registered = get_option( 'mo_2factor_admin_registration_status' );
470
+ $configured_2FA_method = $Mo2fdbQueries->get_user_detail( 'mo2f_configured_2FA_method', $user->ID );
471
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
472
  $is_2FA_configured = $configured_2FA_method == 'NONE' ? 0 : 1;
473
 
474
  $selectedMethod = $mo2f_second_factor;
488
  $selectedMethod = MO2f_Utility::mo2f_decode_2_factor( $mo2f_second_factor, "servertowpdb" );
489
  }
490
  if ( $selectedMethod !== 'NONE' ) {
491
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
492
  'mo2f_configured_2FA_method' => $selectedMethod,
493
  'mo2f_' . str_replace( ' ', '', $selectedMethod ) . '_config_status' => true
494
  ) );
503
  $is_customer_admin = current_user_can( 'manage_options' ) && get_option( 'mo2f_miniorange_admin' ) == $user->ID;
504
  $can_display_admin_features = ! $is_customer_admin_registered || $is_customer_admin ? true : false;
505
 
506
+ $is_customer_registered = $Mo2fdbQueries->get_user_detail( 'user_registration_with_miniorange', $user->ID ) == 'SUCCESS' ? true : false;
507
  if ( get_user_meta( $user->ID, 'configure_2FA', true ) ) {
508
 
509
  $current_selected_method = get_user_meta( $user->ID, 'mo2f_2FA_method_to_configure', true ); ?>
539
  <input type="checkbox" id="mo2f_enable_2fa_for_users" name="mo2f_enable_2fa_for_users"
540
  value="1" <?php checked( get_option( 'mo2f_enable_2fa_for_users' ) == 1 );
541
 
542
+ if ( $Mo2fdbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID ) != 'MO_2_FACTOR_PLUGIN_SETTINGS' ) {
543
  echo 'disabled';
544
  } ?> onChange="this.form.submit()"/>
545
  <?php echo mo2f_lt( 'Enable 2-factor Authentication for Users' ); ?>
553
  <input type="checkbox" id="mo2f_enable_2fa" name="mo2f_enable_2fa"
554
  value="1" <?php checked( get_option( 'mo2f_enable_2fa' ) == 1 );
555
 
556
+ if ( ! in_array( $Mo2fdbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID ), array(
557
  'MO_2_FACTOR_PLUGIN_SETTINGS',
558
  'MO_2_FACTOR_INITIALIZE_TWO_FACTOR'
559
  ) ) ) {
731
  }
732
 
733
  function mo2f_create_2fa_form( $user, $category, $auth_methods ) {
734
+ global $Mo2fdbQueries;
735
  $all_two_factor_methods = array(
736
  "miniOrange QR Code Authentication",
737
  "miniOrange Soft Token",
763
  $two_factor_methods_EC = array_slice( $all_two_factor_methods, 0, 8 );
764
  $two_factor_methods_NC = array_slice( $all_two_factor_methods, 0, 5 );
765
 
766
+ $is_customer_registered = $Mo2fdbQueries->get_user_detail( 'user_registration_with_miniorange', $user->ID ) == 'SUCCESS' ? true : false;
767
 
768
  $is_NC = get_option( 'mo2f_is_NC' );
769
  $is_EC = ! $is_NC;
778
  for ( $j = 0; $j < count( $auth_methods[ $i ] ); $j ++ ) {
779
  $auth_method = $auth_methods[ $i ][ $j ];
780
  $auth_method_abr = str_replace( ' ', '', $auth_method );
781
+ $configured_auth_method = $Mo2fdbQueries->get_user_detail( 'mo2f_configured_2FA_method', $user->ID );
782
  $is_auth_method_selected = ( $configured_auth_method == $auth_method ? true : false );
783
 
784
  $is_auth_method_av = false;
806
  </div>';
807
 
808
  if ( $is_auth_method_av && $category == 'free_plan' ) {
809
+ $is_auth_method_configured = $Mo2fdbQueries->get_user_detail( 'mo2f_' . $auth_method_abr . '_config_status', $user->ID );
810
 
811
  $form .= '<div style="height:40px;width:100%;position: absolute;bottom: 0;background-color:';
812
  $form .= $is_auth_method_selected ? '#48b74b' : '#8daddc';
845
  }
846
 
847
  function show_2_factor_pricing_page( $user ) {
848
+ global $Mo2fdbQueries;
849
 
850
  $is_NC = get_option( 'mo2f_is_NC' );
851
 
852
+ $is_customer_registered = $Mo2fdbQueries->get_user_detail( 'user_registration_with_miniorange', $user->ID ) == 'SUCCESS' ? true : false;
853
 
854
  $mo2f_feature_set = array(
855
  "Authentication Methods",
miniorange_2_factor_settings.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: miniOrange 2 Factor Authentication
4
  * Plugin URI: https://miniorange.com
5
  * Description: This plugin provides various two-factor authentication methods as an additional layer of security after the default wordpress login. We Support Google Authenticator, QR Code, Push Notification, Soft Token and Security Questions(KBA) for Unlimited Users in the free version of the plugin.
6
- * Version: 5.0.5
7
  * Author: miniOrange
8
  * Author URI: https://miniorange.com
9
  * License: GPL2
@@ -46,6 +46,7 @@ class Miniorange_Authentication {
46
  add_action( 'admin_enqueue_scripts', array( $this, 'plugin_settings_script' ) );
47
  add_action( 'admin_notices', array( $this, 'get_customer_SMS_transactions' ) );
48
  add_action( 'admin_notices', array( $this, 'prompt_user_to_setup_two_factor' ) );
 
49
  add_action( 'plugins_loaded', array( $this, 'mo2fa_load_textdomain' ) );
50
  add_action( 'plugins_loaded', array( $this, 'mo2f_update_db_check' ) );
51
 
@@ -160,8 +161,8 @@ class Miniorange_Authentication {
160
  }
161
 
162
  function define_global() {
163
- global $dbQueries;
164
- $dbQueries = new Mo2fDB();
165
  }
166
 
167
  function mo2f_update_db_check() {
@@ -173,72 +174,77 @@ class Miniorange_Authentication {
173
  update_option( 'mo2f_is_NC', 0 );
174
  }
175
 
176
- global $dbQueries;
177
  $user_id = get_site_option( 'mo2f_miniorange_admin' );
178
- $dbQueries->generate_tables();
179
- $dbQueries->insert_user( $user_id, array( 'user_id' => $user_id ) );
180
-
181
- add_option( 'mo2f_phone', get_option( 'user_phone' ) );
182
- add_option( 'mo2f_enable_login_with_2nd_factor', get_option( 'mo2f_show_loginwith_phone' ) );
183
- add_option( 'mo2f_remember_device', get_option( 'mo2f_deviceid_enabled' ) );
184
- add_option( 'mo2f_transactionId', get_option( 'mo2f-login-transactionId' ) );
185
- add_option( 'mo2f_is_NC', 0 );
186
- $phone = get_user_meta( $user_id, 'mo2f_user_phone', true );
187
- $user_phone = $phone ? $phone : get_user_meta( $user_id, 'mo2f_phone', true );
188
-
189
- $dbQueries->update_user_details( $user_id,
190
- array(
191
- 'mo2f_GoogleAuthenticator_config_status' => get_user_meta( $user_id, 'mo2f_google_authentication_status', true ),
192
- 'mo2f_SecurityQuestions_config_status' => get_user_meta( $user_id, 'mo2f_kba_registration_status', true ),
193
- 'mo2f_EmailVerification_config_status' => true,
194
- 'mo2f_AuthyAuthenticator_config_status' => get_user_meta( $user_id, 'mo2f_authy_authentication_status', true ),
195
- 'mo2f_user_email' => get_user_meta( $user_id, 'mo_2factor_map_id_with_email', true ),
196
- 'mo2f_user_phone' => $user_phone,
197
- 'user_registration_with_miniorange' => get_user_meta( $user_id, 'mo_2factor_user_registration_with_miniorange', true ),
198
- 'mobile_registration_status' => get_user_meta( $user_id, 'mo2f_mobile_registration_status', true ),
199
- 'mo2f_configured_2FA_method' => get_user_meta( $user_id, 'mo2f_selected_2factor_method', true ),
200
- 'mo_2factor_user_registration_status' => get_user_meta( $user_id, 'mo_2factor_user_registration_status', true )
201
- ) );
202
-
203
- if ( get_user_meta( $user_id, 'mo2f_mobile_registration_status', true ) ) {
204
- $dbQueries->update_user_details( $user_id,
205
  array(
206
- 'mo2f_miniOrangeSoftToken_config_status' => true,
207
- 'mo2f_miniOrangeQRCodeAuthentication_config_status' => true,
208
- 'mo2f_miniOrangePushNotification_config_status' => true
 
 
 
 
 
 
 
209
  ) );
210
- }
211
 
212
- if ( get_user_meta( $user_id, 'mo2f_otp_registration_status', true ) ) {
213
- $dbQueries->update_user_details( $user_id,
214
- array(
215
- 'mo2f_OTPOverSMS_config_status' => true
216
- ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  }
218
 
219
- $mo2f_external_app_type = get_user_meta( $user_id, 'mo2f_external_app_type', true ) == 'AUTHY 2-FACTOR AUTHENTICATION' ?
220
- 'Authy Authenticator' : 'Google Authenticator';
221
-
222
- update_user_meta( $user_id, 'mo2f_external_app_type', $mo2f_external_app_type );
223
- update_user_meta( $user_id, 'skipped_flow_driven_setup', false );
224
- update_user_meta( $user_id, 'current_modal', 0 );
225
-
226
- delete_option( 'mo2f_show_loginwith_phone' );
227
- delete_option( 'mo2f_deviceid_enabled' );
228
- delete_option( 'mo2f-login-transactionId' );
229
- delete_user_meta( $user_id, 'mo2f_google_authentication_status' );
230
- delete_user_meta( $user_id, 'mo2f_kba_registration_status' );
231
- delete_user_meta( $user_id, 'mo2f_email_verification_status' );
232
- delete_user_meta( $user_id, 'mo2f_authy_authentication_status' );
233
- delete_user_meta( $user_id, 'mo_2factor_map_id_with_email' );
234
- delete_user_meta( $user_id, 'mo_2factor_user_registration_with_miniorange' );
235
- delete_user_meta( $user_id, 'mo2f_mobile_registration_status' );
236
- delete_user_meta( $user_id, 'mo2f_otp_registration_status' );
237
- delete_user_meta( $user_id, 'mo2f_selected_2factor_method' );
238
- delete_user_meta( $user_id, 'mo2f_configure_test_option' );
239
- delete_user_meta( $user_id, 'mo_2factor_user_registration_status' );
240
-
241
- update_option( 'mo2f_existing_user_values_updated', 1 );
242
  }
243
  }
244
 
@@ -282,9 +288,9 @@ class Miniorange_Authentication {
282
  }
283
 
284
  function prompt_user_to_setup_two_factor() {
285
- global $dbQueries;
286
  $user = wp_get_current_user();
287
- $selected_2_Factor_method = $dbQueries->get_user_detail( 'mo2f_configured_2FA_method', $user->ID );
288
  if ( $selected_2_Factor_method == 'NONE' ) {
289
  if ( get_option( 'mo2f_enable_2fa_for_users' ) || ( current_user_can( 'manage_options' ) && get_option( 'mo2f_miniorange_admin' ) == $user->ID ) ) {
290
  echo '<div class="is-dismissible notice notice-warning"><p><b>' . mo2f_lt( "miniOrange 2-Factor Plugin: " ) . '</b>' . mo2f_lt( 'You have not configured your 2-factor authentication method yet.' ) .
@@ -294,6 +300,37 @@ class Miniorange_Authentication {
294
  }
295
  }
296
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
 
298
  function mo_auth_success_message() {
299
  $message = get_option( 'mo2f_message' ); ?>
@@ -385,17 +422,17 @@ class Miniorange_Authentication {
385
  }
386
 
387
  function mo_2_factor_enable_frontend_style() {
388
- wp_enqueue_style( 'mo2f_frontend_login_style', plugins_url( 'includes/css/front_end_login.css?version=5.0.5', __FILE__ ) );
389
- wp_enqueue_style( 'bootstrap_style', plugins_url( 'includes/css/bootstrap.min.css?version=5.0.5', __FILE__ ) );
390
- wp_enqueue_style( 'mo_2_factor_admin_settings_phone_style', plugins_url( 'includes/css/phone.css?version=5.0.5', __FILE__ ) );
391
  wp_enqueue_style( 'mo_2_factor_wpb-fa', plugins_url( 'includes/css/font-awesome.min.css', __FILE__ ) );
392
- wp_enqueue_style( 'mo2f_login_popup_style', plugins_url( 'includes/css/mo2f_login_popup_ui.css?version=5.0.5', __FILE__ ) );
393
  }
394
 
395
  function plugin_settings_style() {
396
- wp_enqueue_style( 'mo_2_factor_admin_settings_style', plugins_url( 'includes/css/style_settings.css?version=5.0.5', __FILE__ ) );
397
- wp_enqueue_style( 'mo_2_factor_admin_settings_phone_style', plugins_url( 'includes/css/phone.css?version=5.0.5', __FILE__ ) );
398
- wp_enqueue_style( 'bootstrap_style', plugins_url( 'includes/css/bootstrap.min.css?version=5.0.5', __FILE__ ) );
399
  wp_enqueue_style( 'mo_2_factor_wpb-fa', plugins_url( 'includes/css/font-awesome.min.css', __FILE__ ) );
400
  }
401
 
@@ -411,7 +448,7 @@ class Miniorange_Authentication {
411
  function miniorange_auth_save_settings() {
412
 
413
  global $user;
414
- global $dbQueries;
415
  $defaultCustomerKey = $this->defaultCustomerKey;
416
  $defaultApiKey = $this->defaultApiKey;
417
 
@@ -467,8 +504,8 @@ class Miniorange_Authentication {
467
  $email = strtolower( $email );
468
  update_option( 'mo2f_email', $email );
469
 
470
- $dbQueries->insert_user( $user_id, array( 'user_id' => $user_id ) );
471
- $dbQueries->update_user_details( $user->ID, array( 'mo2f_user_phone' => $phone ) );
472
 
473
  update_option( 'mo2f_admin_company', $company );
474
  update_option( 'mo2f_admin_first_name', $firstName );
@@ -491,21 +528,21 @@ class Miniorange_Authentication {
491
  if ( strcasecmp( $content['status'], 'SUCCESS' ) == 0 ) {
492
 
493
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "OTP_SENT" ) . ' <b>' . ( get_option( 'mo2f_email' ) ) . ' </b>. ' . Mo2fConstants:: langTranslate( "ENTER_OTP" ) );
494
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => 'MO_2_FACTOR_OTP_DELIVERED_SUCCESS' ) );
495
  update_user_meta( $user->ID, 'mo2f_email_otp_count', 1 );
496
  update_user_meta( $user->ID, 'mo_2fa_verify_otp_create_account', $content['txId'] );
497
  $this->mo_auth_show_success_message();
498
  } else {
499
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ERROR_IN_SENDING_OTP_OVER_EMAIL" ) );
500
 
501
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => 'MO_2_FACTOR_OTP_DELIVERED_FAILURE' ) );
502
  $this->mo_auth_show_error_message();
503
  }
504
 
505
  } else { //customer already exists, redirect him to login page
506
 
507
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ACCOUNT_ALREADY_EXISTS" ) );
508
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => 'MO_2_FACTOR_VERIFY_CUSTOMER' ) );
509
  $this->mo_auth_show_success_message();
510
  }
511
 
@@ -517,9 +554,9 @@ class Miniorange_Authentication {
517
  }
518
 
519
  if ( isset( $_POST['option'] ) and $_POST['option'] == "mo2f_goto_verifycustomer" ) {
520
- $dbQueries->insert_user( $user_id, array( 'user_id' => $user_id ) );
521
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ENTER_YOUR_EMAIL_PASSWORD" ) );
522
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => 'MO_2_FACTOR_VERIFY_CUSTOMER' ) );
523
  $this->mo_auth_show_success_message();
524
  }
525
 
@@ -528,7 +565,7 @@ class Miniorange_Authentication {
528
  //validation and sanitization
529
  $email = '';
530
  $password = '';
531
- $dbQueries->insert_user( $user_id, array( 'user_id' => $user_id ) );
532
 
533
 
534
  if ( MO2f_Utility::mo2f_check_empty_or_null( $_POST['email'] ) || MO2f_Utility::mo2f_check_empty_or_null( $_POST['password'] ) ) {
@@ -556,7 +593,7 @@ class Miniorange_Authentication {
556
  update_option( 'mo2f_api_key', $customerKey['apiKey'] );
557
  update_option( 'mo2f_customer_token', $customerKey['token'] );
558
  update_option( 'mo2f_app_secret', $customerKey['appSecret'] );
559
- $dbQueries->update_user_details( $user->ID, array( 'mo2f_user_phone' => $customerKey['phone'] ) );
560
  update_option( 'mo2f_miniorange_admin', $user->ID );
561
 
562
  //gayathri1
@@ -567,18 +604,18 @@ class Miniorange_Authentication {
567
  delete_option( 'mo2f_password' );
568
  update_option( 'mo_2factor_admin_registration_status', 'MO_2_FACTOR_CUSTOMER_REGISTERED_SUCCESS' );
569
 
570
- $dbQueries->update_user_details( $user->ID, array(
571
  'mo2f_EmailVerification_config_status' => $mo2f_emailVerification_config_status,
572
  'mo2f_user_email' => get_option( 'mo2f_email' ),
573
  'user_registration_with_miniorange' => 'SUCCESS',
574
  'mo2f_2factor_enable_2fa_byusers' => 1,
575
  ) );
576
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_PLUGIN_SETTINGS';
577
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
578
  update_user_meta( $user->ID, 'skipped_flow_driven_setup', $skipped_flow_driven_setup );
579
  update_user_meta( $user->ID, 'current_modal', $current_modal );
580
  $configured_2FA_method = 'NONE';
581
- $user_email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
582
  $enduser = new Two_Factor_Setup();
583
  $userinfo = json_decode( $enduser->mo2f_get_userinfo( $user_email ), true );
584
 
@@ -595,7 +632,7 @@ class Miniorange_Authentication {
595
  if ( get_option( 'mo2f_is_NC' ) == 0 ) {
596
 
597
  $auth_method_abr = str_replace( ' ', '', $configured_2FA_method );
598
- $dbQueries->update_user_details( $user->ID, array(
599
  'mo2f_configured_2FA_method' => $configured_2FA_method,
600
  'mo2f_' . $auth_method_abr . '_config_status' => true
601
  ) );
@@ -624,7 +661,7 @@ class Miniorange_Authentication {
624
  } else {
625
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "INVALID_EMAIL_OR_PASSWORD" ) );
626
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_VERIFY_CUSTOMER';
627
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
628
  $this->mo_auth_show_error_message();
629
  }
630
 
@@ -632,7 +669,7 @@ class Miniorange_Authentication {
632
  } else {
633
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "INVALID_EMAIL_OR_PASSWORD" ) );
634
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_VERIFY_CUSTOMER';
635
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
636
  $this->mo_auth_show_error_message();
637
  }
638
 
@@ -641,7 +678,7 @@ class Miniorange_Authentication {
641
 
642
  if ( isset( $_POST['option'] ) and $_POST['option'] == 'mo_2factor_phone_verification' ) { //at registration time
643
  $phone = sanitize_text_field( $_POST['phone_number'] );
644
- $dbQueries->update_user_details( $user->ID, array( 'mo2f_user_phone' => $phone ) );
645
 
646
  $phone = str_replace( ' ', '', $phone );
647
  $auth_type = 'SMS';
@@ -651,7 +688,7 @@ class Miniorange_Authentication {
651
 
652
  if ( strcasecmp( $send_otp_response['status'], 'SUCCESS' ) == 0 ) {
653
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_SUCCESS';
654
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
655
  update_user_meta( $user->ID, 'mo_2fa_verify_otp_create_account', $send_otp_response['txId'] );
656
 
657
  if ( get_user_meta( $user->ID, 'mo2f_sms_otp_count', true ) ) {
@@ -666,7 +703,7 @@ class Miniorange_Authentication {
666
  } else {
667
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ERROR_WHILE_SENDING_SMS" ) );
668
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_FAILURE';
669
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
670
  $this->mo_auth_show_error_message();
671
  }
672
 
@@ -684,20 +721,34 @@ class Miniorange_Authentication {
684
  update_user_meta( $user->ID, 'mo2f_email_otp_count', 1 );
685
  }
686
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_SUCCESS';
687
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
688
  update_user_meta( $user->ID, 'mo_2fa_verify_otp_create_account', $content['txId'] );
689
 
690
  $this->mo_auth_show_success_message();
691
  } else {
692
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ERROR_IN_SENDING_EMAIL" ) );
693
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_FAILURE';
694
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
695
  $this->mo_auth_show_error_message();
696
  }
697
 
698
 
699
  }
700
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
701
  if ( isset( $_POST['option'] ) and $_POST['option'] == "mo_2factor_validate_otp" ) { //validate OTP over email for admin
702
 
703
  //validation and sanitization
@@ -725,7 +776,7 @@ class Miniorange_Authentication {
725
  delete_user_meta( $user->ID, 'mo_2fa_verify_otp_create_account' );
726
  } else { // OTP Validation failed.
727
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "INVALID_OTP" ) );
728
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => 'MO_2_FACTOR_OTP_DELIVERED_FAILURE' ) );
729
  $this->mo_auth_show_error_message();
730
  }
731
  }
@@ -761,7 +812,7 @@ class Miniorange_Authentication {
761
  delete_user_meta( $user->ID, 'mo_2fa_verify_otp_create_account' );
762
  } else {
763
  update_option( 'mo2f_message', 'Invalid OTP. Please try again.' );
764
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => 'MO_2_FACTOR_OTP_DELIVERED_FAILURE' ) );
765
  $this->mo_auth_show_error_message();
766
  }
767
  }
@@ -811,7 +862,7 @@ class Miniorange_Authentication {
811
  }
812
 
813
  if ( isset( $_POST['option'] ) and $_POST['option'] == 'mo_auth_login_settings_save' ) {
814
- $mo_2factor_user_registration_status = $dbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
815
  if ( $mo_2factor_user_registration_status == 'MO_2_FACTOR_PLUGIN_SETTINGS' ) {
816
 
817
  update_option( 'mo2f_login_option', isset( $_POST['mo2f_login_option'] ) ? $_POST['mo2f_login_option'] : 0 );
@@ -862,7 +913,7 @@ class Miniorange_Authentication {
862
  delete_option( 'mo2f_transactionId' );
863
  delete_user_meta( $user->ID, 'mo2f_sms_otp_count' );
864
  delete_user_meta( $user->ID, 'mo2f_email_otp_count' );
865
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => '' ) );
866
 
867
  }
868
 
@@ -908,7 +959,7 @@ class Miniorange_Authentication {
908
  }
909
 
910
  if ( isset( $_POST['option'] ) && $_POST['option'] == 'mo2f_go_back_to_reconfigure_2FA' ) {
911
- $configured_2FA_method = $dbQueries->get_user_detail( 'mo2f_configured_2FA_method', $user->ID );
912
 
913
  $current_modal = get_user_meta( $user->ID, 'current_modal', true );
914
 
@@ -916,10 +967,10 @@ class Miniorange_Authentication {
916
  update_user_meta( $user->ID, 'mo2f_2FA_method_to_configure', $configured_2FA_method );
917
 
918
  delete_user_meta( $user->ID, 'mo2f_2FA_method_to_test' );
919
- $dbQueries->update_user_details( $user->ID, array( 'mo2f_' . str_replace( ' ', '', $configured_2FA_method ) . '_config_status' => false ) );
920
 
921
  if ( $configured_2FA_method == 'Google Authenticator' ) {
922
- $dbQueries->update_user_details( $user->ID, array(
923
  "mo2f_GoogleAuthenticator_config_status" => false
924
  ) );
925
  delete_user_meta( $user->ID, 'mo2f_external_app_type' );
@@ -928,13 +979,13 @@ class Miniorange_Authentication {
928
  MO2f_Utility::unset_session_variables( $session_variables );
929
 
930
  } else {
931
- $dbQueries->update_user_details( $user->ID, array(
932
  'mo2f_miniOrangeQRCodeAuthentication_config_status' => false,
933
  'mo2f_miniOrangeSoftToken_config_status' => false,
934
  'mo2f_miniOrangePushNotification_config_status' => false
935
  ) );
936
  }
937
- $dbQueries->update_user_details( $user->ID, array( "mo2f_configured_2FA_method" => '' ) );
938
 
939
  update_option( 'mo2f_message', "" );
940
  }
@@ -998,7 +1049,7 @@ class Miniorange_Authentication {
998
  }
999
 
1000
  if ( isset( $_POST['option'] ) && $_POST['option'] == 'mo2f_go_back_to_reconfigure_2FA' ) {
1001
- $configured_2FA_method = $dbQueries->get_user_detail( 'mo2f_configured_2FA_method', $user->ID );
1002
 
1003
  $current_modal = get_user_meta( $user->ID, 'current_modal', true );
1004
 
@@ -1006,23 +1057,23 @@ class Miniorange_Authentication {
1006
  update_user_meta( $user->ID, 'mo2f_2FA_method_to_configure', $configured_2FA_method );
1007
 
1008
  delete_user_meta( $user->ID, 'mo2f_2FA_method_to_test' );
1009
- $dbQueries->update_user_details( $user->ID, array( 'mo2f_' . str_replace( ' ', '', $configured_2FA_method ) . '_config_status' => false ) );
1010
 
1011
  if ( $configured_2FA_method == 'Google Authenticator' ) {
1012
- $dbQueries->update_user_details( $user->ID, array(
1013
  "mo2f_GoogleAuthenticator_config_status" => false
1014
  ) );
1015
  delete_user_meta( $user->ID, 'mo2f_external_app_type' );
1016
 
1017
  } else {
1018
- $dbQueries->update_user_details( $user->ID, array(
1019
  'mo2f_miniOrangeQRCodeAuthentication_config_status' => false,
1020
  'mo2f_miniOrangeSoftToken_config_status' => false,
1021
  'mo2f_miniOrangePushNotification_config_status' => false
1022
  ) );
1023
  }
1024
 
1025
- $dbQueries->update_user_details( $user->ID, array( "mo2f_configured_2FA_method" => '' ) );
1026
 
1027
  update_option( 'mo2f_message', "" );
1028
  }
@@ -1050,12 +1101,12 @@ class Miniorange_Authentication {
1050
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "OTP_SENT" ) . ' <b>' . ( get_user_meta( $user->ID, 'user_email', true ) ) . '</b>. ' . Mo2fConstants:: langTranslate( "ENTER_OTP" ) );
1051
  update_user_meta( $user->ID, 'mo_2fa_verify_otp_create_account', $content['txId'] );
1052
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_SUCCESS';
1053
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
1054
  $this->mo_auth_show_success_message();
1055
  } else {
1056
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ERROR_IN_SENDING_EMAIL" ) );
1057
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_FAILURE';
1058
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
1059
  $this->mo_auth_show_error_message();
1060
  }
1061
 
@@ -1067,7 +1118,7 @@ class Miniorange_Authentication {
1067
  $session_variables = array( 'mo2f_qrCode', 'mo2f_transactionId', 'mo2f_show_qr_code' );
1068
  MO2f_Utility::unset_session_variables( $session_variables );
1069
 
1070
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1071
  $TwoFA_method_to_configure = get_user_meta( $user->ID, 'mo2f_2FA_method_to_configure', true );
1072
  $enduser = new Two_Factor_Setup();
1073
  $current_method = MO2f_Utility::mo2f_decode_2_factor( $TwoFA_method_to_configure, "server" );
@@ -1095,7 +1146,7 @@ class Miniorange_Authentication {
1095
  update_user_meta( $user->ID, 'current_modal', 4 );
1096
  }
1097
 
1098
- $dbQueries->update_user_details( $user->ID, array(
1099
  'mo2f_configured_2FA_method' => $selectedMethod,
1100
  'mobile_registration_status' => true,
1101
  'mo2f_miniOrangeQRCodeAuthentication_config_status' => true,
@@ -1158,19 +1209,19 @@ class Miniorange_Authentication {
1158
 
1159
  if ( isset( $_POST['option'] ) and $_POST['option'] == "mo_auth_setting_configuration" ) // redirect to setings page
1160
  {
1161
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => 'MO_2_FACTOR_PLUGIN_SETTINGS' ) );
1162
 
1163
  }
1164
 
1165
  if ( isset( $_POST['option'] ) and $_POST['option'] == "mo_auth_refresh_mobile_qrcode" ) { // refrsh Qrcode for all users
1166
 
1167
- $mo_2factor_user_registration_status = $dbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
1168
  if ( in_array( $mo_2factor_user_registration_status, array(
1169
  'MO_2_FACTOR_INITIALIZE_TWO_FACTOR',
1170
  'MO_2_FACTOR_INITIALIZE_MOBILE_REGISTRATION',
1171
  'MO_2_FACTOR_PLUGIN_SETTINGS'
1172
  ) ) ) {
1173
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1174
  $this->mo2f_get_qr_code_for_mobile( $email, $user->ID );
1175
  } else {
1176
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "REGISTER_WITH_MO" ) );
@@ -1182,7 +1233,7 @@ class Miniorange_Authentication {
1182
 
1183
  if ( isset( $_POST['miniorange_get_started'] ) && isset( $_POST['miniorange_user_reg_nonce'] ) ) { //registration with miniOrange for additional admin and non-admin
1184
  $nonce = $_POST['miniorange_user_reg_nonce'];
1185
- $dbQueries->insert_user( $user_id, array( 'user_id' => $user_id ) );
1186
  if ( ! wp_verify_nonce( $nonce, 'miniorange-2-factor-user-reg-nonce' ) ) {
1187
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "INVALID_REQ" ) );
1188
  } else {
@@ -1222,12 +1273,12 @@ class Miniorange_Authentication {
1222
  $_SESSION['mo2f_transactionId'] = $content['txId'];
1223
  update_option( 'mo2f_transactionId', $content['txId'] );
1224
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_SUCCESS';
1225
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
1226
  update_user_meta( $user->ID, 'mo_2fa_verify_otp_create_account', $content['txId'] );
1227
  $this->mo_auth_show_success_message();
1228
  } else {
1229
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_FAILURE';
1230
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
1231
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ERROR_IN_SENDING_OTP_OVER_EMAIL" ) );
1232
  $this->mo_auth_show_error_message();
1233
  }
@@ -1258,7 +1309,7 @@ class Miniorange_Authentication {
1258
 
1259
  if ( isset( $_POST['option'] ) and $_POST['option'] == 'mo_2factor_backto_user_registration' ) { //back to registration page for additional admin and non-admin
1260
  delete_user_meta( $user->ID, 'user_email' );
1261
- $dbQueries->delete_user_details($user->ID);
1262
  MO2f_Utility::unset_session_variables( 'mo2f_transactionId' );
1263
  delete_option( 'mo2f_transactionId' );
1264
 
@@ -1275,7 +1326,7 @@ class Miniorange_Authentication {
1275
  } else {
1276
  $otp_token = sanitize_text_field( $_POST['otp_token'] );
1277
  }
1278
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1279
  $customer = new Customer_Setup();
1280
  $content = json_decode( $customer->validate_otp_token( 'SOFT TOKEN', $email, null, $otp_token, get_option( 'mo2f_customerKey' ), get_option( 'mo2f_api_key' ) ), true );
1281
  if ( $content['status'] == 'ERROR' ) {
@@ -1317,8 +1368,8 @@ class Miniorange_Authentication {
1317
 
1318
  //if the php session folder has insufficient permissions, temporary options to be used
1319
  $mo2f_transactionId = isset( $_SESSION['mo2f_transactionId'] ) && ! empty( $_SESSION['mo2f_transactionId'] ) ? $_SESSION['mo2f_transactionId'] : get_option( 'mo2f_transactionId' );
1320
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1321
- $selected_2_2factor_method = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1322
  $customer = new Customer_Setup();
1323
  $content = json_decode( $customer->validate_otp_token( get_user_meta( $user->ID, 'mo2f_2FA_method_to_configure', true ), $email, $mo2f_transactionId, $otp_token, get_option( 'mo2f_customerKey' ), get_option( 'mo2f_api_key' ) ), true );
1324
 
@@ -1350,13 +1401,13 @@ class Miniorange_Authentication {
1350
  update_user_meta( $user->ID, 'current_modal', 6 );
1351
  update_option( 'mo2f_message', "" );
1352
  }
1353
- $mo2f_configured_2FA_method = $dbQueries->get_user_detail( 'mo2f_configured_2FA_method', $user->ID );
1354
- $mo2f_EmailVerification_config_status = $dbQueries->get_user_detail( 'mo2f_EmailVerification_config_status', $user->ID );
1355
  if ( ! current_user_can( 'manage_options' ) && $mo2f_configured_2FA_method == 'OUT OF BAND EMAIL' ) {
1356
  if ( $mo2f_EmailVerification_config_status ) {
1357
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "COMPLETED_TEST" ) );
1358
  } else {
1359
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1360
  $enduser = new Two_Factor_Setup();
1361
  $response = json_decode( $enduser->mo2f_update_userinfo( $email, $mo2f_configured_2FA_method, null, null, null ), true );
1362
  update_option( 'mo2f_message', '<b> ' . Mo2fConstants:: langTranslate( "EMAIL_VERFI" ) . '</b> ' . Mo2fConstants:: langTranslate( "SET_AS_2ND_FACTOR" ) );
@@ -1367,7 +1418,7 @@ class Miniorange_Authentication {
1367
  delete_user_meta( $user->ID, 'test_2FA' );
1368
  if ( ! $is_flow_driven_setup ) {
1369
 
1370
- $dbQueries->update_user_details( $user->ID, array(
1371
  'mo_2factor_user_registration_status' => 'MO_2_FACTOR_PLUGIN_SETTINGS',
1372
  'mo2f_EmailVerification_config_status' => true
1373
  ) );
@@ -1380,7 +1431,7 @@ class Miniorange_Authentication {
1380
  if ( isset( $_POST['option'] ) and $_POST['option'] == 'mo2f_out_of_band_error' ) { //push and out of band email denied
1381
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "DENIED_REQUEST" ) );
1382
  delete_user_meta( $user->ID, 'test_2FA' );
1383
- $dbQueries->update_user_details( $user->ID, array(
1384
  'mo_2factor_user_registration_status' => 'MO_2_FACTOR_PLUGIN_SETTINGS',
1385
  'mo2f_EmailVerification_config_status' => true
1386
  ) );
@@ -1403,7 +1454,7 @@ class Miniorange_Authentication {
1403
  } else {
1404
  $otp_token = sanitize_text_field( $_POST['otp_token'] );
1405
  }
1406
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1407
  $customer = new Customer_Setup();
1408
  $content = json_decode( $customer->validate_otp_token( 'GOOGLE AUTHENTICATOR', $email, null, $otp_token, get_option( 'mo2f_customerKey' ), get_option( 'mo2f_api_key' ) ), true );
1409
  if ( json_last_error() == JSON_ERROR_NONE ) {
@@ -1440,7 +1491,7 @@ class Miniorange_Authentication {
1440
  }
1441
 
1442
  if ( isset( $_POST['option'] ) && $_POST['option'] == 'mo2f_configure_google_auth_phone_type' ) {
1443
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1444
  $phone_type = $_POST['mo2f_app_type_radio'];
1445
  $google_auth = new Miniorange_Rba_Attributes();
1446
  $google_response = json_decode( $google_auth->mo2f_google_auth_service( $email ), true );
@@ -1469,7 +1520,7 @@ class Miniorange_Authentication {
1469
  $otpToken = $_POST['google_token'];
1470
  $ga_secret = isset( $_POST['google_auth_secret'] ) ? $_POST['google_auth_secret'] : null;
1471
  if ( MO2f_Utility::mo2f_check_number_length( $otpToken ) ) {
1472
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1473
  $google_auth = new Miniorange_Rba_Attributes();
1474
  $google_response = json_decode( $google_auth->mo2f_validate_google_auth( $email, $otpToken, $ga_secret ), true );
1475
  if ( json_last_error() == JSON_ERROR_NONE ) {
@@ -1491,7 +1542,7 @@ class Miniorange_Authentication {
1491
 
1492
  delete_user_meta( $user->ID, 'configure_2FA' );
1493
 
1494
- $dbQueries->update_user_details( $user->ID, array(
1495
  'mo2f_GoogleAuthenticator_config_status' => true,
1496
  'mo2f_AuthyAuthenticator_config_status' => false,
1497
  'mo2f_configured_2FA_method' => "Google Authenticator",
@@ -1541,7 +1592,7 @@ class Miniorange_Authentication {
1541
 
1542
  if ( isset( $_POST['option'] ) && $_POST['option'] == 'mo2f_configure_authy_authenticator' ) {
1543
  $authy = new Miniorange_Rba_Attributes();
1544
- $user_email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1545
  $authy_response = json_decode( $authy->mo2f_google_auth_service( $user_email ), true );
1546
  if ( json_last_error() == JSON_ERROR_NONE ) {
1547
  if ( $authy_response['status'] == 'SUCCESS' ) {
@@ -1563,7 +1614,7 @@ class Miniorange_Authentication {
1563
  $otpToken = $_POST['mo2f_authy_token'];
1564
  $authy_secret = isset( $_POST['mo2f_authy_secret'] ) ? $_POST['mo2f_authy_secret'] : null;
1565
  if ( MO2f_Utility::mo2f_check_number_length( $otpToken ) ) {
1566
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1567
  $authy_auth = new Miniorange_Rba_Attributes();
1568
  $authy_response = json_decode( $authy_auth->mo2f_validate_google_auth( $email, $otpToken, $authy_secret ), true );
1569
  if ( json_last_error() == JSON_ERROR_NONE ) {
@@ -1573,7 +1624,7 @@ class Miniorange_Authentication {
1573
  if ( json_last_error() == JSON_ERROR_NONE ) {
1574
 
1575
  if ( $response['status'] == 'SUCCESS' ) {
1576
- $dbQueries->update_user_details( $user->ID, array(
1577
  'mo2f_GoogleAuthenticator_config_status' => false,
1578
  'mo2f_AuthyAuthenticator_config_status' => true,
1579
  'mo2f_configured_2FA_method' => "Authy Authenticator",
@@ -1644,7 +1695,7 @@ class Miniorange_Authentication {
1644
  $kba_q3 = addcslashes( stripslashes( $kba_q3 ), '"\\' );
1645
  $kba_a3 = addcslashes( stripslashes( $kba_a3 ), '"\\' );
1646
 
1647
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1648
  $kba_registration = new Two_Factor_Setup();
1649
  $kba_reg_reponse = json_decode( $kba_registration->register_kba_details( $email, $kba_q1, $kba_a1, $kba_q2, $kba_a2, $kba_q3, $kba_a3 ), true );
1650
  if ( json_last_error() == JSON_ERROR_NONE ) {
@@ -1672,7 +1723,7 @@ class Miniorange_Authentication {
1672
  } else if ( $response['status'] == 'SUCCESS' ) {
1673
  delete_user_meta( $user->ID, 'configure_2FA' );
1674
 
1675
- $dbQueries->update_user_details( $user->ID, array(
1676
  'mo2f_SecurityQuestions_config_status' => true,
1677
  'mo2f_configured_2FA_method' => "Security Questions",
1678
  'mo_2factor_user_registration_status' => "MO_2_FACTOR_PLUGIN_SETTINGS"
@@ -1825,8 +1876,8 @@ class Miniorange_Authentication {
1825
  //if the php session folder has insufficient permissions, temporary options to be used
1826
  $mo2f_transactionId = isset( $_SESSION['mo2f_transactionId'] ) && ! empty( $_SESSION['mo2f_transactionId'] ) ? $_SESSION['mo2f_transactionId'] : get_option( 'mo2f_transactionId' );
1827
  $user_phone = isset( $_SESSION['user_phone'] ) && $_SESSION['user_phone'] != 'false' ? $_SESSION['user_phone'] : get_option( 'user_phone_temp' );
1828
- $mo2f_configured_2FA_method = $dbQueries->get_user_detail( 'mo2f_configured_2FA_method', $user->ID );
1829
- $phone = $dbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
1830
  $customer = new Customer_Setup();
1831
  $content = json_decode( $customer->validate_otp_token( $mo2f_configured_2FA_method, null, $mo2f_transactionId, $otp_token, get_option( 'mo2f_customerKey' ), get_option( 'mo2f_api_key' ) ), true );
1832
 
@@ -1836,11 +1887,11 @@ class Miniorange_Authentication {
1836
  } else if ( strcasecmp( $content['status'], 'SUCCESS' ) == 0 ) { //OTP validated
1837
  if ( $phone && strlen( $phone ) >= 4 ) {
1838
  if ( $user_phone != $phone ) {
1839
- $dbQueries->update_user_details( $user->ID, array( 'mobile_registration_status' => false ) );
1840
 
1841
  }
1842
  }
1843
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1844
 
1845
  $enduser = new Two_Factor_Setup();
1846
  $TwoFA_method_to_configure = get_user_meta( $user->ID, 'mo2f_2FA_method_to_configure', true );
@@ -1857,7 +1908,7 @@ class Miniorange_Authentication {
1857
  $this->mo_auth_show_error_message();
1858
  } else if ( $response['status'] == 'SUCCESS' ) {
1859
 
1860
- $dbQueries->update_user_details( $user->ID, array(
1861
  'mo2f_configured_2FA_method' => 'OTP Over SMS',
1862
  'mo2f_OTPOverSMS_config_status' => true,
1863
  'user_registration_with_miniorange' => 'SUCCESS',
@@ -1904,7 +1955,7 @@ class Miniorange_Authentication {
1904
  $selected_action = isset( $_POST['mo2f_selected_action_free_plan'] ) ? $_POST['mo2f_selected_action_free_plan'] : $_POST['mo2f_selected_action_standard_plan'];
1905
  $user_phone = '';
1906
  if ( isset( $_SESSION['user_phone'] ) ) {
1907
- $user_phone = $_SESSION['user_phone'] != 'false' ? $_SESSION['user_phone'] : $dbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
1908
  }
1909
 
1910
  // set it as his 2-factor in the WP database and server
@@ -1915,7 +1966,7 @@ class Miniorange_Authentication {
1915
  $this->mo_auth_show_error_message();
1916
  } else {
1917
  // update in the Wordpress DB
1918
- $dbQueries->update_user_details( $user->ID, array( 'mo2f_configured_2FA_method' => $selected_2FA_method ) );
1919
 
1920
  // update the server
1921
  $this->mo2f_save_2_factor_method( $user, $selected_2FA_method );
@@ -1947,7 +1998,7 @@ class Miniorange_Authentication {
1947
  $selected_2FA_method = $_POST['mo2f_configured_2FA_method_test'];
1948
  $selected_2FA_method_server = MO2f_Utility::mo2f_decode_2_factor( $selected_2FA_method, "server" );
1949
  $customer = new Customer_Setup();
1950
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1951
  $customer_key = get_option( 'mo2f_customerKey' );
1952
  $api_key = get_option( 'mo2f_api_key' );
1953
 
@@ -2017,7 +2068,7 @@ class Miniorange_Authentication {
2017
  }
2018
  }
2019
  } else if ( $selected_2FA_method == 'OTP Over SMS' ) {
2020
- $phone = $dbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
2021
  $response = json_decode( $customer->send_otp_token( $phone, $selected_2FA_method_server, $customer_key, $api_key ), true );
2022
  if ( strcasecmp( $response['status'], 'SUCCESS' ) == 0 ) {
2023
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "OTP_SENT" ) . ' <b>' . ( $phone ) . '</b>. ' . Mo2fConstants:: langTranslate( "ENTER_OTP" ) );
@@ -2102,7 +2153,7 @@ class Miniorange_Authentication {
2102
  }
2103
 
2104
  function mo_auth_deactivate() {
2105
- global $dbQueries;
2106
  $mo2f_register_with_another_email = get_option( 'mo2f_register_with_another_email' );
2107
 
2108
  if ( $mo2f_register_with_another_email ) {
@@ -2117,9 +2168,9 @@ class Miniorange_Authentication {
2117
  }
2118
 
2119
  function mo2f_delete_user_details( $users ) {
2120
- global $dbQueries;
2121
  foreach ( $users as $user ) {
2122
- $dbQueries->delete_user_details( $user->ID );
2123
  delete_user_meta( $user->ID, 'phone_verification_status' );
2124
  delete_user_meta( $user->ID, 'test_2FA' );
2125
  delete_user_meta( $user->ID, 'mo2f_2FA_method_to_configure' );
@@ -2162,8 +2213,76 @@ class Miniorange_Authentication {
2162
  add_action( 'admin_notices', array( $this, 'mo_auth_error_message' ) );
2163
  }
2164
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2165
  function mo2f_create_customer( $user ) {
2166
- global $dbQueries;
2167
  delete_user_meta( $user->ID, 'mo2f_sms_otp_count' );
2168
  delete_user_meta( $user->ID, 'mo2f_email_otp_count' );
2169
  $customer = new Customer_Setup();
@@ -2189,13 +2308,15 @@ class Miniorange_Authentication {
2189
  update_option( 'mo2f_miniorange_admin', $user->ID );
2190
  delete_option( 'mo2f_password' );
2191
  $email = get_option( 'mo2f_email' );
2192
- $dbQueries->update_user_details( $user->ID, array(
2193
  'mo2f_EmailVerification_config_status' => true,
2194
  'user_registration_with_miniorange' => 'SUCCESS',
2195
  'mo2f_user_email' => $email
2196
  ) );
2197
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_PLUGIN_SETTINGS';
2198
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
 
 
2199
 
2200
  update_option( 'mo_2factor_admin_registration_status', 'MO_2_FACTOR_CUSTOMER_REGISTERED_SUCCESS' );
2201
  $enduser = new Two_Factor_Setup();
@@ -2206,7 +2327,7 @@ class Miniorange_Authentication {
2206
  } else {
2207
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ERROR_CREATE_ACC_OTP" ) );
2208
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_FAILURE';
2209
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
2210
  $this->mo_auth_show_error_message();
2211
  }
2212
 
@@ -2215,7 +2336,7 @@ class Miniorange_Authentication {
2215
  } else {
2216
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "INVALID_EMAIL_OR_PASSWORD" ) );
2217
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_VERIFY_CUSTOMER';
2218
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
2219
 
2220
  $this->mo_auth_show_error_message();
2221
  }
@@ -2238,17 +2359,16 @@ class Miniorange_Authentication {
2238
 
2239
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ACCOUNT_CREATED" ) );
2240
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_PLUGIN_SETTINGS';
2241
- $dbQueries->update_user_details( $user->ID, array(
2242
- 'mo2f_2factor_enable_2fa_byusers' => 1,
2243
- 'user_registration_with_miniorange' => 'SUCCESS',
2244
- 'mo2f_configured_2FA_method' => 'NONE',
2245
- 'mo2f_user_email' => $email
 
2246
  ) );
2247
 
2248
  update_option( 'mo_2factor_admin_registration_status', 'MO_2_FACTOR_CUSTOMER_REGISTERED_SUCCESS' );
2249
 
2250
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
2251
-
2252
  $enduser = new Two_Factor_Setup();
2253
  $enduser->mo2f_update_userinfo( $email, 'NONE', null, 'API_2FA', true );
2254
 
@@ -2257,7 +2377,7 @@ class Miniorange_Authentication {
2257
  } else {
2258
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ERROR_CREATE_ACC_OTP" ) );
2259
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_FAILURE';
2260
- $dbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
2261
  $this->mo_auth_show_error_message();
2262
  }
2263
 
@@ -2267,7 +2387,7 @@ class Miniorange_Authentication {
2267
  }
2268
 
2269
  function mo2f_create_user( $user, $email ) {
2270
- global $dbQueries;
2271
  $email = strtolower( $email );
2272
  $enduser = new Two_Factor_Setup();
2273
  $check_user = json_decode( $enduser->mo_check_user_already_exist( $email ), true );
@@ -2279,7 +2399,7 @@ class Miniorange_Authentication {
2279
  } else {
2280
  if ( strcasecmp( $check_user['status'], 'USER_FOUND' ) == 0 ) {
2281
 
2282
- $dbQueries->update_user_details( $user->ID, array(
2283
  'user_registration_with_miniorange' => 'SUCCESS',
2284
  'mo2f_user_email' => $email,
2285
  'mo2f_configured_2FA_method' => 'NONE',
@@ -2303,7 +2423,7 @@ class Miniorange_Authentication {
2303
  } else {
2304
  if ( strcasecmp( $content['status'], 'SUCCESS' ) == 0 ) {
2305
  delete_user_meta( $user->ID, 'user_email' );
2306
- $dbQueries->update_user_details( $user->ID, array(
2307
  'user_registration_with_miniorange' => 'SUCCESS',
2308
  'mo2f_user_email' => $email,
2309
  'mo2f_configured_2FA_method' => 'NONE',
@@ -2374,10 +2494,10 @@ class Miniorange_Authentication {
2374
  }
2375
 
2376
  function mo2f_save_2_factor_method( $user, $mo2f_configured_2FA_method ) {
2377
- global $dbQueries;
2378
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
2379
  $enduser = new Two_Factor_Setup();
2380
- $phone = $dbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
2381
  $current_method = MO2f_Utility::mo2f_decode_2_factor( $mo2f_configured_2FA_method, "server" );
2382
 
2383
  $response = json_decode( $enduser->mo2f_update_userinfo( $email, $current_method, $phone, null, null ), true );
@@ -2387,13 +2507,13 @@ class Miniorange_Authentication {
2387
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( $response['message'] ) );
2388
  $this->mo_auth_show_error_message();
2389
  } else if ( $response['status'] == 'SUCCESS' ) {
2390
- $configured_2fa_method = $dbQueries->get_user_detail( 'mo2f_configured_2FA_method', $user->ID );
2391
 
2392
  if ( in_array( $configured_2fa_method, array( "Google Authenticator", "Authy Authenticator" ) ) ) {
2393
  update_user_meta( $user->ID, 'mo2f_external_app_type', $configured_2fa_method );
2394
  }
2395
 
2396
- $dbQueries->update_user_details( $user->ID, array(
2397
  'mo_2factor_user_registration_status' => 'MO_2_FACTOR_PLUGIN_SETTINGS'
2398
  ) );
2399
  delete_user_meta( $user->ID, 'configure_2FA' );
@@ -2411,9 +2531,9 @@ class Miniorange_Authentication {
2411
  }
2412
 
2413
  function miniorange_email_verification_call( $user ) {
2414
- global $dbQueries;
2415
  $challengeMobile = new Customer_Setup();
2416
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
2417
  $content = $challengeMobile->send_otp_token( $email, 'OUT OF BAND EMAIL', $this->defaultCustomerKey, $this->defaultApiKey );
2418
  $response = json_decode( $content, true );
2419
  if ( json_last_error() == JSON_ERROR_NONE ) { /* Generate out of band email */
@@ -2445,8 +2565,8 @@ class Miniorange_Authentication {
2445
  update_option( 'mo2f_is_NC', 1 );
2446
  }
2447
 
2448
- global $dbQueries;
2449
- $dbQueries->mo_plugin_activate();
2450
  }
2451
 
2452
  function mo_get_2fa_shorcode( $atts ) {
3
  * Plugin Name: miniOrange 2 Factor Authentication
4
  * Plugin URI: https://miniorange.com
5
  * Description: This plugin provides various two-factor authentication methods as an additional layer of security after the default wordpress login. We Support Google Authenticator, QR Code, Push Notification, Soft Token and Security Questions(KBA) for Unlimited Users in the free version of the plugin.
6
+ * Version: 5.0.6
7
  * Author: miniOrange
8
  * Author URI: https://miniorange.com
9
  * License: GPL2
46
  add_action( 'admin_enqueue_scripts', array( $this, 'plugin_settings_script' ) );
47
  add_action( 'admin_notices', array( $this, 'get_customer_SMS_transactions' ) );
48
  add_action( 'admin_notices', array( $this, 'prompt_user_to_setup_two_factor' ) );
49
+ add_action( 'admin_notices', array( $this, 'prompt_user_to_fix_bug' ) );
50
  add_action( 'plugins_loaded', array( $this, 'mo2fa_load_textdomain' ) );
51
  add_action( 'plugins_loaded', array( $this, 'mo2f_update_db_check' ) );
52
 
161
  }
162
 
163
  function define_global() {
164
+ global $Mo2fdbQueries;
165
+ $Mo2fdbQueries = new Mo2fDB();
166
  }
167
 
168
  function mo2f_update_db_check() {
174
  update_option( 'mo2f_is_NC', 0 );
175
  }
176
 
177
+ global $Mo2fdbQueries;
178
  $user_id = get_site_option( 'mo2f_miniorange_admin' );
179
+ if ( $user_id && ! get_option( 'mo2f_is_NC' ) ) {
180
+ $Mo2fdbQueries->generate_tables();
181
+ $Mo2fdbQueries->insert_user( $user_id, array( 'user_id' => $user_id ) );
182
+
183
+ add_option( 'mo2f_phone', get_option( 'user_phone' ) );
184
+ add_option( 'mo2f_enable_login_with_2nd_factor', get_option( 'mo2f_show_loginwith_phone' ) );
185
+ add_option( 'mo2f_remember_device', get_option( 'mo2f_deviceid_enabled' ) );
186
+ add_option( 'mo2f_transactionId', get_option( 'mo2f-login-transactionId' ) );
187
+ add_option( 'mo2f_is_NC', 0 );
188
+ $phone = get_user_meta( $user_id, 'mo2f_user_phone', true );
189
+ $user_phone = $phone ? $phone : get_user_meta( $user_id, 'mo2f_phone', true );
190
+
191
+ $Mo2fdbQueries->update_user_details( $user_id,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  array(
193
+ 'mo2f_GoogleAuthenticator_config_status' => get_user_meta( $user_id, 'mo2f_google_authentication_status', true ),
194
+ 'mo2f_SecurityQuestions_config_status' => get_user_meta( $user_id, 'mo2f_kba_registration_status', true ),
195
+ 'mo2f_EmailVerification_config_status' => true,
196
+ 'mo2f_AuthyAuthenticator_config_status' => get_user_meta( $user_id, 'mo2f_authy_authentication_status', true ),
197
+ 'mo2f_user_email' => get_user_meta( $user_id, 'mo_2factor_map_id_with_email', true ),
198
+ 'mo2f_user_phone' => $user_phone,
199
+ 'user_registration_with_miniorange' => get_user_meta( $user_id, 'mo_2factor_user_registration_with_miniorange', true ),
200
+ 'mobile_registration_status' => get_user_meta( $user_id, 'mo2f_mobile_registration_status', true ),
201
+ 'mo2f_configured_2FA_method' => get_user_meta( $user_id, 'mo2f_selected_2factor_method', true ),
202
+ 'mo_2factor_user_registration_status' => get_user_meta( $user_id, 'mo_2factor_user_registration_status', true )
203
  ) );
 
204
 
205
+ if ( get_user_meta( $user_id, 'mo2f_mobile_registration_status', true ) ) {
206
+ $Mo2fdbQueries->update_user_details( $user_id,
207
+ array(
208
+ 'mo2f_miniOrangeSoftToken_config_status' => true,
209
+ 'mo2f_miniOrangeQRCodeAuthentication_config_status' => true,
210
+ 'mo2f_miniOrangePushNotification_config_status' => true
211
+ ) );
212
+ }
213
+
214
+ if ( get_user_meta( $user_id, 'mo2f_otp_registration_status', true ) ) {
215
+ $Mo2fdbQueries->update_user_details( $user_id,
216
+ array(
217
+ 'mo2f_OTPOverSMS_config_status' => true
218
+ ) );
219
+ }
220
+
221
+ $mo2f_external_app_type = get_user_meta( $user_id, 'mo2f_external_app_type', true ) == 'AUTHY 2-FACTOR AUTHENTICATION' ?
222
+ 'Authy Authenticator' : 'Google Authenticator';
223
+
224
+ update_user_meta( $user_id, 'mo2f_external_app_type', $mo2f_external_app_type );
225
+ update_user_meta( $user_id, 'skipped_flow_driven_setup', false );
226
+ update_user_meta( $user_id, 'current_modal', 0 );
227
+
228
+ delete_option( 'mo2f_show_loginwith_phone' );
229
+ delete_option( 'mo2f_deviceid_enabled' );
230
+ delete_option( 'mo2f-login-transactionId' );
231
+ delete_user_meta( $user_id, 'mo2f_google_authentication_status' );
232
+ delete_user_meta( $user_id, 'mo2f_kba_registration_status' );
233
+ delete_user_meta( $user_id, 'mo2f_email_verification_status' );
234
+ delete_user_meta( $user_id, 'mo2f_authy_authentication_status' );
235
+ delete_user_meta( $user_id, 'mo_2factor_map_id_with_email' );
236
+ delete_user_meta( $user_id, 'mo_2factor_user_registration_with_miniorange' );
237
+ delete_user_meta( $user_id, 'mo2f_mobile_registration_status' );
238
+ delete_user_meta( $user_id, 'mo2f_otp_registration_status' );
239
+ delete_user_meta( $user_id, 'mo2f_selected_2factor_method' );
240
+ delete_user_meta( $user_id, 'mo2f_configure_test_option' );
241
+ delete_user_meta( $user_id, 'mo_2factor_user_registration_status' );
242
+
243
+ update_option( 'mo2f_existing_user_values_updated', 1 );
244
+
245
  }
246
 
247
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
  }
249
  }
250
 
288
  }
289
 
290
  function prompt_user_to_setup_two_factor() {
291
+ global $Mo2fdbQueries;
292
  $user = wp_get_current_user();
293
+ $selected_2_Factor_method = $Mo2fdbQueries->get_user_detail( 'mo2f_configured_2FA_method', $user->ID );
294
  if ( $selected_2_Factor_method == 'NONE' ) {
295
  if ( get_option( 'mo2f_enable_2fa_for_users' ) || ( current_user_can( 'manage_options' ) && get_option( 'mo2f_miniorange_admin' ) == $user->ID ) ) {
296
  echo '<div class="is-dismissible notice notice-warning"><p><b>' . mo2f_lt( "miniOrange 2-Factor Plugin: " ) . '</b>' . mo2f_lt( 'You have not configured your 2-factor authentication method yet.' ) .
300
  }
301
  }
302
 
303
+ function prompt_user_to_fix_bug() {
304
+ $user = wp_get_current_user();
305
+ $iconurl = plugin_dir_url( __FILE__ ) . 'includes/images/mo2fa_bug.png';
306
+ if ( !get_option( 'mo2f_is_NC' ) && ! get_option( 'mo2f_bug_fix_done' ) && current_user_can( 'manage_options' ) && get_option( 'mo2f_miniorange_admin' ) == $user->ID ) {
307
+ echo '<div class="is-dismissible notice notice-warning"><p><b>' . mo2f_lt( "miniOrange 2-Factor Plugin: " ) . '</b>' . mo2f_lt( 'If you facing issues after the plugin update
308
+ like not seeing anything in the Account Setup Tab [ ' . '<a class="btn btn-link" data-toggle="collapse" id="showpreviewofbug" href="#previewofbug"
309
+ aria-expanded="false">' . mo2f_lt( 'See preview' ) . '</a>'
310
+ . ' ] click on Clear / Refresh Cache.' ) . '<br><span style="color:red">' . mo2f_lt( ' Please click on ' ) . '<b>' . mo2f_lt( 'Dismiss Notice ' ) . '</b>' . mo2f_lt( ' if you are not facing any issues.' ) . '</span>' .
311
+ '<div><br>
312
+ <form name="f" method="post" action="" id="mo2f_fix_bug_form">
313
+ <input type="hidden" name="option" value="mo2f_fix_bug_option"/>
314
+ <button style="display:inline-block;float:left" class="button button-primary button-large" id="mo2f_fix_bug" name="mo2f_fix_bug"
315
+ onclick="this.form.submit()" >' . mo2f_lt( "Clear / Refresh Cache" ) . ' </button></form>
316
+ <form name="f" method="post" action="" id="mo2f_dismiss_notice_form">
317
+ <input type="hidden" name="option" value="mo2f_dismiss_notice_option"/>
318
+ <button style="display:inline-block;float:left;margin-left:30px;" class="button button-primary button-large" id="mo2f_dismiss_notice" name="mo2f_fix_bug"
319
+ onclick="this.form.submit()" >' . mo2f_lt( "Dismiss Notice" ) . ' </button></form></div><br><br>
320
+ <div class="mo2f_collapse" id="previewofbug" style="height:300px;">
321
+ <center><br>
322
+ <img style="height:300px;"
323
+ src="' . $iconurl . '">
324
+ </center>
325
+ </div>
326
+ <br>
327
+ </div>
328
+
329
+
330
+ ';
331
+ }
332
+ }
333
+
334
 
335
  function mo_auth_success_message() {
336
  $message = get_option( 'mo2f_message' ); ?>
422
  }
423
 
424
  function mo_2_factor_enable_frontend_style() {
425
+ wp_enqueue_style( 'mo2f_frontend_login_style', plugins_url( 'includes/css/front_end_login.css?version=5.0.6', __FILE__ ) );
426
+ wp_enqueue_style( 'bootstrap_style', plugins_url( 'includes/css/bootstrap.min.css?version=5.0.6', __FILE__ ) );
427
+ wp_enqueue_style( 'mo_2_factor_admin_settings_phone_style', plugins_url( 'includes/css/phone.css?version=5.0.6', __FILE__ ) );
428
  wp_enqueue_style( 'mo_2_factor_wpb-fa', plugins_url( 'includes/css/font-awesome.min.css', __FILE__ ) );
429
+ wp_enqueue_style( 'mo2f_login_popup_style', plugins_url( 'includes/css/mo2f_login_popup_ui.css?version=5.0.6', __FILE__ ) );
430
  }
431
 
432
  function plugin_settings_style() {
433
+ wp_enqueue_style( 'mo_2_factor_admin_settings_style', plugins_url( 'includes/css/style_settings.css?version=5.0.6', __FILE__ ) );
434
+ wp_enqueue_style( 'mo_2_factor_admin_settings_phone_style', plugins_url( 'includes/css/phone.css?version=5.0.6', __FILE__ ) );
435
+ wp_enqueue_style( 'bootstrap_style', plugins_url( 'includes/css/bootstrap.min.css?version=5.0.6', __FILE__ ) );
436
  wp_enqueue_style( 'mo_2_factor_wpb-fa', plugins_url( 'includes/css/font-awesome.min.css', __FILE__ ) );
437
  }
438
 
448
  function miniorange_auth_save_settings() {
449
 
450
  global $user;
451
+ global $Mo2fdbQueries;
452
  $defaultCustomerKey = $this->defaultCustomerKey;
453
  $defaultApiKey = $this->defaultApiKey;
454
 
504
  $email = strtolower( $email );
505
  update_option( 'mo2f_email', $email );
506
 
507
+ $Mo2fdbQueries->insert_user( $user_id, array( 'user_id' => $user_id ) );
508
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo2f_user_phone' => $phone ) );
509
 
510
  update_option( 'mo2f_admin_company', $company );
511
  update_option( 'mo2f_admin_first_name', $firstName );
528
  if ( strcasecmp( $content['status'], 'SUCCESS' ) == 0 ) {
529
 
530
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "OTP_SENT" ) . ' <b>' . ( get_option( 'mo2f_email' ) ) . ' </b>. ' . Mo2fConstants:: langTranslate( "ENTER_OTP" ) );
531
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => 'MO_2_FACTOR_OTP_DELIVERED_SUCCESS' ) );
532
  update_user_meta( $user->ID, 'mo2f_email_otp_count', 1 );
533
  update_user_meta( $user->ID, 'mo_2fa_verify_otp_create_account', $content['txId'] );
534
  $this->mo_auth_show_success_message();
535
  } else {
536
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ERROR_IN_SENDING_OTP_OVER_EMAIL" ) );
537
 
538
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => 'MO_2_FACTOR_OTP_DELIVERED_FAILURE' ) );
539
  $this->mo_auth_show_error_message();
540
  }
541
 
542
  } else { //customer already exists, redirect him to login page
543
 
544
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ACCOUNT_ALREADY_EXISTS" ) );
545
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => 'MO_2_FACTOR_VERIFY_CUSTOMER' ) );
546
  $this->mo_auth_show_success_message();
547
  }
548
 
554
  }
555
 
556
  if ( isset( $_POST['option'] ) and $_POST['option'] == "mo2f_goto_verifycustomer" ) {
557
+ $Mo2fdbQueries->insert_user( $user_id, array( 'user_id' => $user_id ) );
558
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ENTER_YOUR_EMAIL_PASSWORD" ) );
559
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => 'MO_2_FACTOR_VERIFY_CUSTOMER' ) );
560
  $this->mo_auth_show_success_message();
561
  }
562
 
565
  //validation and sanitization
566
  $email = '';
567
  $password = '';
568
+ $Mo2fdbQueries->insert_user( $user_id, array( 'user_id' => $user_id ) );
569
 
570
 
571
  if ( MO2f_Utility::mo2f_check_empty_or_null( $_POST['email'] ) || MO2f_Utility::mo2f_check_empty_or_null( $_POST['password'] ) ) {
593
  update_option( 'mo2f_api_key', $customerKey['apiKey'] );
594
  update_option( 'mo2f_customer_token', $customerKey['token'] );
595
  update_option( 'mo2f_app_secret', $customerKey['appSecret'] );
596
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo2f_user_phone' => $customerKey['phone'] ) );
597
  update_option( 'mo2f_miniorange_admin', $user->ID );
598
 
599
  //gayathri1
604
  delete_option( 'mo2f_password' );
605
  update_option( 'mo_2factor_admin_registration_status', 'MO_2_FACTOR_CUSTOMER_REGISTERED_SUCCESS' );
606
 
607
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
608
  'mo2f_EmailVerification_config_status' => $mo2f_emailVerification_config_status,
609
  'mo2f_user_email' => get_option( 'mo2f_email' ),
610
  'user_registration_with_miniorange' => 'SUCCESS',
611
  'mo2f_2factor_enable_2fa_byusers' => 1,
612
  ) );
613
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_PLUGIN_SETTINGS';
614
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
615
  update_user_meta( $user->ID, 'skipped_flow_driven_setup', $skipped_flow_driven_setup );
616
  update_user_meta( $user->ID, 'current_modal', $current_modal );
617
  $configured_2FA_method = 'NONE';
618
+ $user_email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
619
  $enduser = new Two_Factor_Setup();
620
  $userinfo = json_decode( $enduser->mo2f_get_userinfo( $user_email ), true );
621
 
632
  if ( get_option( 'mo2f_is_NC' ) == 0 ) {
633
 
634
  $auth_method_abr = str_replace( ' ', '', $configured_2FA_method );
635
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
636
  'mo2f_configured_2FA_method' => $configured_2FA_method,
637
  'mo2f_' . $auth_method_abr . '_config_status' => true
638
  ) );
661
  } else {
662
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "INVALID_EMAIL_OR_PASSWORD" ) );
663
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_VERIFY_CUSTOMER';
664
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
665
  $this->mo_auth_show_error_message();
666
  }
667
 
669
  } else {
670
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "INVALID_EMAIL_OR_PASSWORD" ) );
671
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_VERIFY_CUSTOMER';
672
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
673
  $this->mo_auth_show_error_message();
674
  }
675
 
678
 
679
  if ( isset( $_POST['option'] ) and $_POST['option'] == 'mo_2factor_phone_verification' ) { //at registration time
680
  $phone = sanitize_text_field( $_POST['phone_number'] );
681
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo2f_user_phone' => $phone ) );
682
 
683
  $phone = str_replace( ' ', '', $phone );
684
  $auth_type = 'SMS';
688
 
689
  if ( strcasecmp( $send_otp_response['status'], 'SUCCESS' ) == 0 ) {
690
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_SUCCESS';
691
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
692
  update_user_meta( $user->ID, 'mo_2fa_verify_otp_create_account', $send_otp_response['txId'] );
693
 
694
  if ( get_user_meta( $user->ID, 'mo2f_sms_otp_count', true ) ) {
703
  } else {
704
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ERROR_WHILE_SENDING_SMS" ) );
705
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_FAILURE';
706
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
707
  $this->mo_auth_show_error_message();
708
  }
709
 
721
  update_user_meta( $user->ID, 'mo2f_email_otp_count', 1 );
722
  }
723
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_SUCCESS';
724
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
725
  update_user_meta( $user->ID, 'mo_2fa_verify_otp_create_account', $content['txId'] );
726
 
727
  $this->mo_auth_show_success_message();
728
  } else {
729
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ERROR_IN_SENDING_EMAIL" ) );
730
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_FAILURE';
731
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
732
  $this->mo_auth_show_error_message();
733
  }
734
 
735
 
736
  }
737
 
738
+ if ( isset( $_POST['option'] ) and $_POST['option'] == "mo2f_fix_bug_option" ) {
739
+ $user_id = get_option('mo2f_miniorange_admin');
740
+ $check_if_user_column_exists = $Mo2fdbQueries->check_if_user_column_exists($user_id);
741
+ update_option( 'mo2f_bug_fix_done', 1 );
742
+
743
+ if($check_if_user_column_exists == 0)
744
+ $this->mo2f_fix_the_bug();
745
+ }
746
+
747
+ if ( isset( $_POST['option'] ) and $_POST['option'] == "mo2f_dismiss_notice_option" ) {
748
+ update_option( 'mo2f_bug_fix_done', 1 );
749
+ }
750
+
751
+
752
  if ( isset( $_POST['option'] ) and $_POST['option'] == "mo_2factor_validate_otp" ) { //validate OTP over email for admin
753
 
754
  //validation and sanitization
776
  delete_user_meta( $user->ID, 'mo_2fa_verify_otp_create_account' );
777
  } else { // OTP Validation failed.
778
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "INVALID_OTP" ) );
779
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => 'MO_2_FACTOR_OTP_DELIVERED_FAILURE' ) );
780
  $this->mo_auth_show_error_message();
781
  }
782
  }
812
  delete_user_meta( $user->ID, 'mo_2fa_verify_otp_create_account' );
813
  } else {
814
  update_option( 'mo2f_message', 'Invalid OTP. Please try again.' );
815
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => 'MO_2_FACTOR_OTP_DELIVERED_FAILURE' ) );
816
  $this->mo_auth_show_error_message();
817
  }
818
  }
862
  }
863
 
864
  if ( isset( $_POST['option'] ) and $_POST['option'] == 'mo_auth_login_settings_save' ) {
865
+ $mo_2factor_user_registration_status = $Mo2fdbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
866
  if ( $mo_2factor_user_registration_status == 'MO_2_FACTOR_PLUGIN_SETTINGS' ) {
867
 
868
  update_option( 'mo2f_login_option', isset( $_POST['mo2f_login_option'] ) ? $_POST['mo2f_login_option'] : 0 );
913
  delete_option( 'mo2f_transactionId' );
914
  delete_user_meta( $user->ID, 'mo2f_sms_otp_count' );
915
  delete_user_meta( $user->ID, 'mo2f_email_otp_count' );
916
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => '' ) );
917
 
918
  }
919
 
959
  }
960
 
961
  if ( isset( $_POST['option'] ) && $_POST['option'] == 'mo2f_go_back_to_reconfigure_2FA' ) {
962
+ $configured_2FA_method = $Mo2fdbQueries->get_user_detail( 'mo2f_configured_2FA_method', $user->ID );
963
 
964
  $current_modal = get_user_meta( $user->ID, 'current_modal', true );
965
 
967
  update_user_meta( $user->ID, 'mo2f_2FA_method_to_configure', $configured_2FA_method );
968
 
969
  delete_user_meta( $user->ID, 'mo2f_2FA_method_to_test' );
970
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo2f_' . str_replace( ' ', '', $configured_2FA_method ) . '_config_status' => false ) );
971
 
972
  if ( $configured_2FA_method == 'Google Authenticator' ) {
973
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
974
  "mo2f_GoogleAuthenticator_config_status" => false
975
  ) );
976
  delete_user_meta( $user->ID, 'mo2f_external_app_type' );
979
  MO2f_Utility::unset_session_variables( $session_variables );
980
 
981
  } else {
982
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
983
  'mo2f_miniOrangeQRCodeAuthentication_config_status' => false,
984
  'mo2f_miniOrangeSoftToken_config_status' => false,
985
  'mo2f_miniOrangePushNotification_config_status' => false
986
  ) );
987
  }
988
+ $Mo2fdbQueries->update_user_details( $user->ID, array( "mo2f_configured_2FA_method" => '' ) );
989
 
990
  update_option( 'mo2f_message', "" );
991
  }
1049
  }
1050
 
1051
  if ( isset( $_POST['option'] ) && $_POST['option'] == 'mo2f_go_back_to_reconfigure_2FA' ) {
1052
+ $configured_2FA_method = $Mo2fdbQueries->get_user_detail( 'mo2f_configured_2FA_method', $user->ID );
1053
 
1054
  $current_modal = get_user_meta( $user->ID, 'current_modal', true );
1055
 
1057
  update_user_meta( $user->ID, 'mo2f_2FA_method_to_configure', $configured_2FA_method );
1058
 
1059
  delete_user_meta( $user->ID, 'mo2f_2FA_method_to_test' );
1060
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo2f_' . str_replace( ' ', '', $configured_2FA_method ) . '_config_status' => false ) );
1061
 
1062
  if ( $configured_2FA_method == 'Google Authenticator' ) {
1063
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
1064
  "mo2f_GoogleAuthenticator_config_status" => false
1065
  ) );
1066
  delete_user_meta( $user->ID, 'mo2f_external_app_type' );
1067
 
1068
  } else {
1069
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
1070
  'mo2f_miniOrangeQRCodeAuthentication_config_status' => false,
1071
  'mo2f_miniOrangeSoftToken_config_status' => false,
1072
  'mo2f_miniOrangePushNotification_config_status' => false
1073
  ) );
1074
  }
1075
 
1076
+ $Mo2fdbQueries->update_user_details( $user->ID, array( "mo2f_configured_2FA_method" => '' ) );
1077
 
1078
  update_option( 'mo2f_message', "" );
1079
  }
1101
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "OTP_SENT" ) . ' <b>' . ( get_user_meta( $user->ID, 'user_email', true ) ) . '</b>. ' . Mo2fConstants:: langTranslate( "ENTER_OTP" ) );
1102
  update_user_meta( $user->ID, 'mo_2fa_verify_otp_create_account', $content['txId'] );
1103
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_SUCCESS';
1104
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
1105
  $this->mo_auth_show_success_message();
1106
  } else {
1107
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ERROR_IN_SENDING_EMAIL" ) );
1108
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_FAILURE';
1109
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
1110
  $this->mo_auth_show_error_message();
1111
  }
1112
 
1118
  $session_variables = array( 'mo2f_qrCode', 'mo2f_transactionId', 'mo2f_show_qr_code' );
1119
  MO2f_Utility::unset_session_variables( $session_variables );
1120
 
1121
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1122
  $TwoFA_method_to_configure = get_user_meta( $user->ID, 'mo2f_2FA_method_to_configure', true );
1123
  $enduser = new Two_Factor_Setup();
1124
  $current_method = MO2f_Utility::mo2f_decode_2_factor( $TwoFA_method_to_configure, "server" );
1146
  update_user_meta( $user->ID, 'current_modal', 4 );
1147
  }
1148
 
1149
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
1150
  'mo2f_configured_2FA_method' => $selectedMethod,
1151
  'mobile_registration_status' => true,
1152
  'mo2f_miniOrangeQRCodeAuthentication_config_status' => true,
1209
 
1210
  if ( isset( $_POST['option'] ) and $_POST['option'] == "mo_auth_setting_configuration" ) // redirect to setings page
1211
  {
1212
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => 'MO_2_FACTOR_PLUGIN_SETTINGS' ) );
1213
 
1214
  }
1215
 
1216
  if ( isset( $_POST['option'] ) and $_POST['option'] == "mo_auth_refresh_mobile_qrcode" ) { // refrsh Qrcode for all users
1217
 
1218
+ $mo_2factor_user_registration_status = $Mo2fdbQueries->get_user_detail( 'mo_2factor_user_registration_status', $user->ID );
1219
  if ( in_array( $mo_2factor_user_registration_status, array(
1220
  'MO_2_FACTOR_INITIALIZE_TWO_FACTOR',
1221
  'MO_2_FACTOR_INITIALIZE_MOBILE_REGISTRATION',
1222
  'MO_2_FACTOR_PLUGIN_SETTINGS'
1223
  ) ) ) {
1224
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1225
  $this->mo2f_get_qr_code_for_mobile( $email, $user->ID );
1226
  } else {
1227
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "REGISTER_WITH_MO" ) );
1233
 
1234
  if ( isset( $_POST['miniorange_get_started'] ) && isset( $_POST['miniorange_user_reg_nonce'] ) ) { //registration with miniOrange for additional admin and non-admin
1235
  $nonce = $_POST['miniorange_user_reg_nonce'];
1236
+ $Mo2fdbQueries->insert_user( $user_id, array( 'user_id' => $user_id ) );
1237
  if ( ! wp_verify_nonce( $nonce, 'miniorange-2-factor-user-reg-nonce' ) ) {
1238
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "INVALID_REQ" ) );
1239
  } else {
1273
  $_SESSION['mo2f_transactionId'] = $content['txId'];
1274
  update_option( 'mo2f_transactionId', $content['txId'] );
1275
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_SUCCESS';
1276
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
1277
  update_user_meta( $user->ID, 'mo_2fa_verify_otp_create_account', $content['txId'] );
1278
  $this->mo_auth_show_success_message();
1279
  } else {
1280
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_FAILURE';
1281
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
1282
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ERROR_IN_SENDING_OTP_OVER_EMAIL" ) );
1283
  $this->mo_auth_show_error_message();
1284
  }
1309
 
1310
  if ( isset( $_POST['option'] ) and $_POST['option'] == 'mo_2factor_backto_user_registration' ) { //back to registration page for additional admin and non-admin
1311
  delete_user_meta( $user->ID, 'user_email' );
1312
+ $Mo2fdbQueries->delete_user_details( $user->ID );
1313
  MO2f_Utility::unset_session_variables( 'mo2f_transactionId' );
1314
  delete_option( 'mo2f_transactionId' );
1315
 
1326
  } else {
1327
  $otp_token = sanitize_text_field( $_POST['otp_token'] );
1328
  }
1329
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1330
  $customer = new Customer_Setup();
1331
  $content = json_decode( $customer->validate_otp_token( 'SOFT TOKEN', $email, null, $otp_token, get_option( 'mo2f_customerKey' ), get_option( 'mo2f_api_key' ) ), true );
1332
  if ( $content['status'] == 'ERROR' ) {
1368
 
1369
  //if the php session folder has insufficient permissions, temporary options to be used
1370
  $mo2f_transactionId = isset( $_SESSION['mo2f_transactionId'] ) && ! empty( $_SESSION['mo2f_transactionId'] ) ? $_SESSION['mo2f_transactionId'] : get_option( 'mo2f_transactionId' );
1371
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1372
+ $selected_2_2factor_method = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1373
  $customer = new Customer_Setup();
1374
  $content = json_decode( $customer->validate_otp_token( get_user_meta( $user->ID, 'mo2f_2FA_method_to_configure', true ), $email, $mo2f_transactionId, $otp_token, get_option( 'mo2f_customerKey' ), get_option( 'mo2f_api_key' ) ), true );
1375
 
1401
  update_user_meta( $user->ID, 'current_modal', 6 );
1402
  update_option( 'mo2f_message', "" );
1403
  }
1404
+ $mo2f_configured_2FA_method = $Mo2fdbQueries->get_user_detail( 'mo2f_configured_2FA_method', $user->ID );
1405
+ $mo2f_EmailVerification_config_status = $Mo2fdbQueries->get_user_detail( 'mo2f_EmailVerification_config_status', $user->ID );
1406
  if ( ! current_user_can( 'manage_options' ) && $mo2f_configured_2FA_method == 'OUT OF BAND EMAIL' ) {
1407
  if ( $mo2f_EmailVerification_config_status ) {
1408
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "COMPLETED_TEST" ) );
1409
  } else {
1410
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1411
  $enduser = new Two_Factor_Setup();
1412
  $response = json_decode( $enduser->mo2f_update_userinfo( $email, $mo2f_configured_2FA_method, null, null, null ), true );
1413
  update_option( 'mo2f_message', '<b> ' . Mo2fConstants:: langTranslate( "EMAIL_VERFI" ) . '</b> ' . Mo2fConstants:: langTranslate( "SET_AS_2ND_FACTOR" ) );
1418
  delete_user_meta( $user->ID, 'test_2FA' );
1419
  if ( ! $is_flow_driven_setup ) {
1420
 
1421
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
1422
  'mo_2factor_user_registration_status' => 'MO_2_FACTOR_PLUGIN_SETTINGS',
1423
  'mo2f_EmailVerification_config_status' => true
1424
  ) );
1431
  if ( isset( $_POST['option'] ) and $_POST['option'] == 'mo2f_out_of_band_error' ) { //push and out of band email denied
1432
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "DENIED_REQUEST" ) );
1433
  delete_user_meta( $user->ID, 'test_2FA' );
1434
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
1435
  'mo_2factor_user_registration_status' => 'MO_2_FACTOR_PLUGIN_SETTINGS',
1436
  'mo2f_EmailVerification_config_status' => true
1437
  ) );
1454
  } else {
1455
  $otp_token = sanitize_text_field( $_POST['otp_token'] );
1456
  }
1457
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1458
  $customer = new Customer_Setup();
1459
  $content = json_decode( $customer->validate_otp_token( 'GOOGLE AUTHENTICATOR', $email, null, $otp_token, get_option( 'mo2f_customerKey' ), get_option( 'mo2f_api_key' ) ), true );
1460
  if ( json_last_error() == JSON_ERROR_NONE ) {
1491
  }
1492
 
1493
  if ( isset( $_POST['option'] ) && $_POST['option'] == 'mo2f_configure_google_auth_phone_type' ) {
1494
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1495
  $phone_type = $_POST['mo2f_app_type_radio'];
1496
  $google_auth = new Miniorange_Rba_Attributes();
1497
  $google_response = json_decode( $google_auth->mo2f_google_auth_service( $email ), true );
1520
  $otpToken = $_POST['google_token'];
1521
  $ga_secret = isset( $_POST['google_auth_secret'] ) ? $_POST['google_auth_secret'] : null;
1522
  if ( MO2f_Utility::mo2f_check_number_length( $otpToken ) ) {
1523
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1524
  $google_auth = new Miniorange_Rba_Attributes();
1525
  $google_response = json_decode( $google_auth->mo2f_validate_google_auth( $email, $otpToken, $ga_secret ), true );
1526
  if ( json_last_error() == JSON_ERROR_NONE ) {
1542
 
1543
  delete_user_meta( $user->ID, 'configure_2FA' );
1544
 
1545
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
1546
  'mo2f_GoogleAuthenticator_config_status' => true,
1547
  'mo2f_AuthyAuthenticator_config_status' => false,
1548
  'mo2f_configured_2FA_method' => "Google Authenticator",
1592
 
1593
  if ( isset( $_POST['option'] ) && $_POST['option'] == 'mo2f_configure_authy_authenticator' ) {
1594
  $authy = new Miniorange_Rba_Attributes();
1595
+ $user_email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1596
  $authy_response = json_decode( $authy->mo2f_google_auth_service( $user_email ), true );
1597
  if ( json_last_error() == JSON_ERROR_NONE ) {
1598
  if ( $authy_response['status'] == 'SUCCESS' ) {
1614
  $otpToken = $_POST['mo2f_authy_token'];
1615
  $authy_secret = isset( $_POST['mo2f_authy_secret'] ) ? $_POST['mo2f_authy_secret'] : null;
1616
  if ( MO2f_Utility::mo2f_check_number_length( $otpToken ) ) {
1617
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1618
  $authy_auth = new Miniorange_Rba_Attributes();
1619
  $authy_response = json_decode( $authy_auth->mo2f_validate_google_auth( $email, $otpToken, $authy_secret ), true );
1620
  if ( json_last_error() == JSON_ERROR_NONE ) {
1624
  if ( json_last_error() == JSON_ERROR_NONE ) {
1625
 
1626
  if ( $response['status'] == 'SUCCESS' ) {
1627
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
1628
  'mo2f_GoogleAuthenticator_config_status' => false,
1629
  'mo2f_AuthyAuthenticator_config_status' => true,
1630
  'mo2f_configured_2FA_method' => "Authy Authenticator",
1695
  $kba_q3 = addcslashes( stripslashes( $kba_q3 ), '"\\' );
1696
  $kba_a3 = addcslashes( stripslashes( $kba_a3 ), '"\\' );
1697
 
1698
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1699
  $kba_registration = new Two_Factor_Setup();
1700
  $kba_reg_reponse = json_decode( $kba_registration->register_kba_details( $email, $kba_q1, $kba_a1, $kba_q2, $kba_a2, $kba_q3, $kba_a3 ), true );
1701
  if ( json_last_error() == JSON_ERROR_NONE ) {
1723
  } else if ( $response['status'] == 'SUCCESS' ) {
1724
  delete_user_meta( $user->ID, 'configure_2FA' );
1725
 
1726
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
1727
  'mo2f_SecurityQuestions_config_status' => true,
1728
  'mo2f_configured_2FA_method' => "Security Questions",
1729
  'mo_2factor_user_registration_status' => "MO_2_FACTOR_PLUGIN_SETTINGS"
1876
  //if the php session folder has insufficient permissions, temporary options to be used
1877
  $mo2f_transactionId = isset( $_SESSION['mo2f_transactionId'] ) && ! empty( $_SESSION['mo2f_transactionId'] ) ? $_SESSION['mo2f_transactionId'] : get_option( 'mo2f_transactionId' );
1878
  $user_phone = isset( $_SESSION['user_phone'] ) && $_SESSION['user_phone'] != 'false' ? $_SESSION['user_phone'] : get_option( 'user_phone_temp' );
1879
+ $mo2f_configured_2FA_method = $Mo2fdbQueries->get_user_detail( 'mo2f_configured_2FA_method', $user->ID );
1880
+ $phone = $Mo2fdbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
1881
  $customer = new Customer_Setup();
1882
  $content = json_decode( $customer->validate_otp_token( $mo2f_configured_2FA_method, null, $mo2f_transactionId, $otp_token, get_option( 'mo2f_customerKey' ), get_option( 'mo2f_api_key' ) ), true );
1883
 
1887
  } else if ( strcasecmp( $content['status'], 'SUCCESS' ) == 0 ) { //OTP validated
1888
  if ( $phone && strlen( $phone ) >= 4 ) {
1889
  if ( $user_phone != $phone ) {
1890
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mobile_registration_status' => false ) );
1891
 
1892
  }
1893
  }
1894
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
1895
 
1896
  $enduser = new Two_Factor_Setup();
1897
  $TwoFA_method_to_configure = get_user_meta( $user->ID, 'mo2f_2FA_method_to_configure', true );
1908
  $this->mo_auth_show_error_message();
1909
  } else if ( $response['status'] == 'SUCCESS' ) {
1910
 
1911
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
1912
  'mo2f_configured_2FA_method' => 'OTP Over SMS',
1913
  'mo2f_OTPOverSMS_config_status' => true,
1914
  'user_registration_with_miniorange' => 'SUCCESS',
1955
  $selected_action = isset( $_POST['mo2f_selected_action_free_plan'] ) ? $_POST['mo2f_selected_action_free_plan'] : $_POST['mo2f_selected_action_standard_plan'];
1956
  $user_phone = '';
1957
  if ( isset( $_SESSION['user_phone'] ) ) {
1958
+ $user_phone = $_SESSION['user_phone'] != 'false' ? $_SESSION['user_phone'] : $Mo2fdbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
1959
  }
1960
 
1961
  // set it as his 2-factor in the WP database and server
1966
  $this->mo_auth_show_error_message();
1967
  } else {
1968
  // update in the Wordpress DB
1969
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo2f_configured_2FA_method' => $selected_2FA_method ) );
1970
 
1971
  // update the server
1972
  $this->mo2f_save_2_factor_method( $user, $selected_2FA_method );
1998
  $selected_2FA_method = $_POST['mo2f_configured_2FA_method_test'];
1999
  $selected_2FA_method_server = MO2f_Utility::mo2f_decode_2_factor( $selected_2FA_method, "server" );
2000
  $customer = new Customer_Setup();
2001
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
2002
  $customer_key = get_option( 'mo2f_customerKey' );
2003
  $api_key = get_option( 'mo2f_api_key' );
2004
 
2068
  }
2069
  }
2070
  } else if ( $selected_2FA_method == 'OTP Over SMS' ) {
2071
+ $phone = $Mo2fdbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
2072
  $response = json_decode( $customer->send_otp_token( $phone, $selected_2FA_method_server, $customer_key, $api_key ), true );
2073
  if ( strcasecmp( $response['status'], 'SUCCESS' ) == 0 ) {
2074
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "OTP_SENT" ) . ' <b>' . ( $phone ) . '</b>. ' . Mo2fConstants:: langTranslate( "ENTER_OTP" ) );
2153
  }
2154
 
2155
  function mo_auth_deactivate() {
2156
+ global $Mo2fdbQueries;
2157
  $mo2f_register_with_another_email = get_option( 'mo2f_register_with_another_email' );
2158
 
2159
  if ( $mo2f_register_with_another_email ) {
2168
  }
2169
 
2170
  function mo2f_delete_user_details( $users ) {
2171
+ global $Mo2fdbQueries;
2172
  foreach ( $users as $user ) {
2173
+ $Mo2fdbQueries->delete_user_details( $user->ID );
2174
  delete_user_meta( $user->ID, 'phone_verification_status' );
2175
  delete_user_meta( $user->ID, 'test_2FA' );
2176
  delete_user_meta( $user->ID, 'mo2f_2FA_method_to_configure' );
2213
  add_action( 'admin_notices', array( $this, 'mo_auth_error_message' ) );
2214
  }
2215
 
2216
+ function mo2f_fix_the_bug() {
2217
+ global $Mo2fdbQueries;
2218
+ $user_id = get_site_option( 'mo2f_miniorange_admin' );
2219
+ $Mo2fdbQueries->generate_tables();
2220
+ $Mo2fdbQueries->insert_user( $user_id, array( 'user_id' => $user_id ) );
2221
+
2222
+ add_option( 'mo2f_phone', get_option( 'user_phone' ) );
2223
+ add_option( 'mo2f_enable_login_with_2nd_factor', get_option( 'mo2f_show_loginwith_phone' ) );
2224
+ add_option( 'mo2f_remember_device', get_option( 'mo2f_deviceid_enabled' ) );
2225
+ add_option( 'mo2f_transactionId', get_option( 'mo2f-login-transactionId' ) );
2226
+ add_option( 'mo2f_is_NC', 0 );
2227
+ $phone = get_user_meta( $user_id, 'mo2f_user_phone', true );
2228
+ $user_phone = $phone ? $phone : get_user_meta( $user_id, 'mo2f_phone', true );
2229
+
2230
+ $Mo2fdbQueries->update_user_details( $user_id,
2231
+ array(
2232
+ 'mo2f_GoogleAuthenticator_config_status' => get_user_meta( $user_id, 'mo2f_google_authentication_status', true ),
2233
+ 'mo2f_SecurityQuestions_config_status' => get_user_meta( $user_id, 'mo2f_kba_registration_status', true ),
2234
+ 'mo2f_EmailVerification_config_status' => true,
2235
+ 'mo2f_AuthyAuthenticator_config_status' => get_user_meta( $user_id, 'mo2f_authy_authentication_status', true ),
2236
+ 'mo2f_user_email' => get_user_meta( $user_id, 'mo_2factor_map_id_with_email', true ),
2237
+ 'mo2f_user_phone' => $user_phone,
2238
+ 'user_registration_with_miniorange' => get_user_meta( $user_id, 'mo_2factor_user_registration_with_miniorange', true ),
2239
+ 'mobile_registration_status' => get_user_meta( $user_id, 'mo2f_mobile_registration_status', true ),
2240
+ 'mo2f_configured_2FA_method' => get_user_meta( $user_id, 'mo2f_selected_2factor_method', true ),
2241
+ 'mo_2factor_user_registration_status' => get_user_meta( $user_id, 'mo_2factor_user_registration_status', true )
2242
+ ) );
2243
+
2244
+ if ( get_user_meta( $user_id, 'mo2f_mobile_registration_status', true ) ) {
2245
+ $Mo2fdbQueries->update_user_details( $user_id,
2246
+ array(
2247
+ 'mo2f_miniOrangeSoftToken_config_status' => true,
2248
+ 'mo2f_miniOrangeQRCodeAuthentication_config_status' => true,
2249
+ 'mo2f_miniOrangePushNotification_config_status' => true
2250
+ ) );
2251
+ }
2252
+
2253
+ if ( get_user_meta( $user_id, 'mo2f_otp_registration_status', true ) ) {
2254
+ $Mo2fdbQueries->update_user_details( $user_id,
2255
+ array(
2256
+ 'mo2f_OTPOverSMS_config_status' => true
2257
+ ) );
2258
+ }
2259
+
2260
+ $mo2f_external_app_type = get_user_meta( $user_id, 'mo2f_external_app_type', true ) == 'AUTHY 2-FACTOR AUTHENTICATION' ?
2261
+ 'Authy Authenticator' : 'Google Authenticator';
2262
+
2263
+ update_user_meta( $user_id, 'mo2f_external_app_type', $mo2f_external_app_type );
2264
+ update_user_meta( $user_id, 'skipped_flow_driven_setup', false );
2265
+ update_user_meta( $user_id, 'current_modal', 0 );
2266
+
2267
+ delete_option( 'mo2f_show_loginwith_phone' );
2268
+ delete_option( 'mo2f_deviceid_enabled' );
2269
+ delete_option( 'mo2f-login-transactionId' );
2270
+ delete_user_meta( $user_id, 'mo2f_google_authentication_status' );
2271
+ delete_user_meta( $user_id, 'mo2f_kba_registration_status' );
2272
+ delete_user_meta( $user_id, 'mo2f_email_verification_status' );
2273
+ delete_user_meta( $user_id, 'mo2f_authy_authentication_status' );
2274
+ delete_user_meta( $user_id, 'mo_2factor_map_id_with_email' );
2275
+ delete_user_meta( $user_id, 'mo_2factor_user_registration_with_miniorange' );
2276
+ delete_user_meta( $user_id, 'mo2f_mobile_registration_status' );
2277
+ delete_user_meta( $user_id, 'mo2f_otp_registration_status' );
2278
+ delete_user_meta( $user_id, 'mo2f_selected_2factor_method' );
2279
+ delete_user_meta( $user_id, 'mo2f_configure_test_option' );
2280
+ delete_user_meta( $user_id, 'mo_2factor_user_registration_status' );
2281
+
2282
+ }
2283
+
2284
  function mo2f_create_customer( $user ) {
2285
+ global $Mo2fdbQueries;
2286
  delete_user_meta( $user->ID, 'mo2f_sms_otp_count' );
2287
  delete_user_meta( $user->ID, 'mo2f_email_otp_count' );
2288
  $customer = new Customer_Setup();
2308
  update_option( 'mo2f_miniorange_admin', $user->ID );
2309
  delete_option( 'mo2f_password' );
2310
  $email = get_option( 'mo2f_email' );
2311
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
2312
  'mo2f_EmailVerification_config_status' => true,
2313
  'user_registration_with_miniorange' => 'SUCCESS',
2314
  'mo2f_user_email' => $email
2315
  ) );
2316
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_PLUGIN_SETTINGS';
2317
+
2318
+
2319
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
2320
 
2321
  update_option( 'mo_2factor_admin_registration_status', 'MO_2_FACTOR_CUSTOMER_REGISTERED_SUCCESS' );
2322
  $enduser = new Two_Factor_Setup();
2327
  } else {
2328
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ERROR_CREATE_ACC_OTP" ) );
2329
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_FAILURE';
2330
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
2331
  $this->mo_auth_show_error_message();
2332
  }
2333
 
2336
  } else {
2337
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "INVALID_EMAIL_OR_PASSWORD" ) );
2338
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_VERIFY_CUSTOMER';
2339
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
2340
 
2341
  $this->mo_auth_show_error_message();
2342
  }
2359
 
2360
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ACCOUNT_CREATED" ) );
2361
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_PLUGIN_SETTINGS';
2362
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
2363
+ 'mo2f_2factor_enable_2fa_byusers' => 1,
2364
+ 'user_registration_with_miniorange' => 'SUCCESS',
2365
+ 'mo2f_configured_2FA_method' => 'NONE',
2366
+ 'mo2f_user_email' => $email,
2367
+ 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status
2368
  ) );
2369
 
2370
  update_option( 'mo_2factor_admin_registration_status', 'MO_2_FACTOR_CUSTOMER_REGISTERED_SUCCESS' );
2371
 
 
 
2372
  $enduser = new Two_Factor_Setup();
2373
  $enduser->mo2f_update_userinfo( $email, 'NONE', null, 'API_2FA', true );
2374
 
2377
  } else {
2378
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( "ERROR_CREATE_ACC_OTP" ) );
2379
  $mo_2factor_user_registration_status = 'MO_2_FACTOR_OTP_DELIVERED_FAILURE';
2380
+ $Mo2fdbQueries->update_user_details( $user->ID, array( 'mo_2factor_user_registration_status' => $mo_2factor_user_registration_status ) );
2381
  $this->mo_auth_show_error_message();
2382
  }
2383
 
2387
  }
2388
 
2389
  function mo2f_create_user( $user, $email ) {
2390
+ global $Mo2fdbQueries;
2391
  $email = strtolower( $email );
2392
  $enduser = new Two_Factor_Setup();
2393
  $check_user = json_decode( $enduser->mo_check_user_already_exist( $email ), true );
2399
  } else {
2400
  if ( strcasecmp( $check_user['status'], 'USER_FOUND' ) == 0 ) {
2401
 
2402
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
2403
  'user_registration_with_miniorange' => 'SUCCESS',
2404
  'mo2f_user_email' => $email,
2405
  'mo2f_configured_2FA_method' => 'NONE',
2423
  } else {
2424
  if ( strcasecmp( $content['status'], 'SUCCESS' ) == 0 ) {
2425
  delete_user_meta( $user->ID, 'user_email' );
2426
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
2427
  'user_registration_with_miniorange' => 'SUCCESS',
2428
  'mo2f_user_email' => $email,
2429
  'mo2f_configured_2FA_method' => 'NONE',
2494
  }
2495
 
2496
  function mo2f_save_2_factor_method( $user, $mo2f_configured_2FA_method ) {
2497
+ global $Mo2fdbQueries;
2498
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
2499
  $enduser = new Two_Factor_Setup();
2500
+ $phone = $Mo2fdbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
2501
  $current_method = MO2f_Utility::mo2f_decode_2_factor( $mo2f_configured_2FA_method, "server" );
2502
 
2503
  $response = json_decode( $enduser->mo2f_update_userinfo( $email, $current_method, $phone, null, null ), true );
2507
  update_option( 'mo2f_message', Mo2fConstants:: langTranslate( $response['message'] ) );
2508
  $this->mo_auth_show_error_message();
2509
  } else if ( $response['status'] == 'SUCCESS' ) {
2510
+ $configured_2fa_method = $Mo2fdbQueries->get_user_detail( 'mo2f_configured_2FA_method', $user->ID );
2511
 
2512
  if ( in_array( $configured_2fa_method, array( "Google Authenticator", "Authy Authenticator" ) ) ) {
2513
  update_user_meta( $user->ID, 'mo2f_external_app_type', $configured_2fa_method );
2514
  }
2515
 
2516
+ $Mo2fdbQueries->update_user_details( $user->ID, array(
2517
  'mo_2factor_user_registration_status' => 'MO_2_FACTOR_PLUGIN_SETTINGS'
2518
  ) );
2519
  delete_user_meta( $user->ID, 'configure_2FA' );
2531
  }
2532
 
2533
  function miniorange_email_verification_call( $user ) {
2534
+ global $Mo2fdbQueries;
2535
  $challengeMobile = new Customer_Setup();
2536
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
2537
  $content = $challengeMobile->send_otp_token( $email, 'OUT OF BAND EMAIL', $this->defaultCustomerKey, $this->defaultApiKey );
2538
  $response = json_decode( $content, true );
2539
  if ( json_last_error() == JSON_ERROR_NONE ) { /* Generate out of band email */
2565
  update_option( 'mo2f_is_NC', 1 );
2566
  }
2567
 
2568
+ global $Mo2fdbQueries;
2569
+ $Mo2fdbQueries->mo_plugin_activate();
2570
  }
2571
 
2572
  function mo_get_2fa_shorcode( $atts ) {
miniorange_2_factor_support.php CHANGED
@@ -2,10 +2,10 @@
2
 
3
  function mo2f_support() {
4
  global $user;
5
- global $dbQueries;
6
  $user = wp_get_current_user();
7
- $email = $dbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
8
- $phone = $dbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
9
  $user_email = $email ? $email : $user->user_email;
10
  $user_phone = $phone != 'false' ? $phone : '';
11
  ?>
2
 
3
  function mo2f_support() {
4
  global $user;
5
+ global $Mo2fdbQueries;
6
  $user = wp_get_current_user();
7
+ $email = $Mo2fdbQueries->get_user_detail( 'mo2f_user_email', $user->ID );
8
+ $phone = $Mo2fdbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
9
  $user_email = $email ? $email : $user->user_email;
10
  $user_phone = $phone != 'false' ? $phone : '';
11
  ?>
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: google authenticator, two factor authentication, two factor, 2FA, 2 factor
5
  Requires at least: 3.0.1
6
  Tested up to: 4.9.4
7
  Requires PHP: 5.3.0
8
- Stable tag: 5.0.5
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -219,6 +219,9 @@ miniOrange authentication service has 15+ authentication methods.One time passco
219
 
220
  == Changelog ==
221
 
 
 
 
222
  = 5.0.5 =
223
  * Google Authenticator (2FA) : Bug fix for user entry during plugin update.
224
 
@@ -484,6 +487,9 @@ More descriptive setup messages and UI changes.
484
 
485
  == Upgrade Notice ==
486
 
 
 
 
487
  = 5.0.5 =
488
  * Google Authenticator (2FA) : Bug fix for user entry during plugin update.
489
 
5
  Requires at least: 3.0.1
6
  Tested up to: 4.9.4
7
  Requires PHP: 5.3.0
8
+ Stable tag: 5.0.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
219
 
220
  == Changelog ==
221
 
222
+ = 5.0.6 =
223
+ * Google Authenticator (2FA) : Bug Fix for existing customers facing Cache issue.
224
+
225
  = 5.0.5 =
226
  * Google Authenticator (2FA) : Bug fix for user entry during plugin update.
227
 
487
 
488
  == Upgrade Notice ==
489
 
490
+ = 5.0.6 =
491
+ * Google Authenticator (2FA) : Bug Fix for existing customers who upgraded from 4.5.x version to versions between 5.0.0 and 5.0.4 and are facing issues with the Account Setup Tab.
492
+
493
  = 5.0.5 =
494
  * Google Authenticator (2FA) : Bug fix for user entry during plugin update.
495
 
uninstall.php CHANGED
@@ -7,10 +7,10 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
7
 
8
  include_once dirname( __FILE__ ) . '/database/database_functions.php';
9
  global $wpdb;
10
- $dbQueries = new Mo2fDB();
11
 
12
  $table_name = $wpdb->prefix . 'mo2f_user_details';
13
- $dbQueries->drop_table( $table_name );
14
 
15
  if ( ! is_multisite() ) {
16
 
@@ -54,6 +54,7 @@ if ( ! is_multisite() ) {
54
  delete_option( 'mo2f_phone' );
55
  delete_option( 'mo2f_existing_user_values_updated' );
56
  delete_option( 'mo2f_dbversion' );
 
57
 
58
  delete_option( 'mo2f_admin_first_name' );
59
  delete_option( 'mo2_admin_last_name' );
@@ -119,6 +120,8 @@ if ( ! is_multisite() ) {
119
  delete_option( 'mo2f_admin_first_name' );
120
  delete_option( 'mo2_admin_last_name' );
121
  delete_option( 'mo2f_admin_company' );
 
 
122
  //delete all stored key-value pairs for the roles
123
  global $wp_roles;
124
  if ( ! isset( $wp_roles ) ) {
7
 
8
  include_once dirname( __FILE__ ) . '/database/database_functions.php';
9
  global $wpdb;
10
+ $Mo2fdbQueries = new Mo2fDB();
11
 
12
  $table_name = $wpdb->prefix . 'mo2f_user_details';
13
+ $Mo2fdbQueries->drop_table( $table_name );
14
 
15
  if ( ! is_multisite() ) {
16
 
54
  delete_option( 'mo2f_phone' );
55
  delete_option( 'mo2f_existing_user_values_updated' );
56
  delete_option( 'mo2f_dbversion' );
57
+ delete_option( 'mo2f_bug_fix_done' );
58
 
59
  delete_option( 'mo2f_admin_first_name' );
60
  delete_option( 'mo2_admin_last_name' );
120
  delete_option( 'mo2f_admin_first_name' );
121
  delete_option( 'mo2_admin_last_name' );
122
  delete_option( 'mo2f_admin_company' );
123
+
124
+ delete_option( 'mo2f_bug_fix_done' );
125
  //delete all stored key-value pairs for the roles
126
  global $wp_roles;
127
  if ( ! isset( $wp_roles ) ) {
views/admin_setup_select_2_factor_method CHANGED
@@ -3,13 +3,13 @@
3
  include dirname( __FILE__ ) . '/select_2_factor_authentication_method';
4
 
5
  function start_flow_driven_setup( $user ) {
6
- global $dbQueries;
7
  $current_modal = get_user_meta( $user->ID, 'current_modal', true );
8
  $is_large_modal = in_array( get_user_meta( $user->ID, 'mo2f_2FA_method_to_configure', true ), array(
9
  "Google Authenticator",
10
  "Security Questions"
11
  ) ) && $current_modal == "3" ? true : false;
12
- $configured_2FA_method = $dbQueries->get_user_detail( 'mo2f_configured_2FA_method', $user->ID );
13
  $twoFA_method_to_configure = get_user_meta( $user->ID, 'mo2f_2FA_method_to_configure', true );
14
  $mo2f_message = get_option( 'mo2f_message' );
15
  ?>
3
  include dirname( __FILE__ ) . '/select_2_factor_authentication_method';
4
 
5
  function start_flow_driven_setup( $user ) {
6
+ global $Mo2fdbQueries;
7
  $current_modal = get_user_meta( $user->ID, 'current_modal', true );
8
  $is_large_modal = in_array( get_user_meta( $user->ID, 'mo2f_2FA_method_to_configure', true ), array(
9
  "Google Authenticator",
10
  "Security Questions"
11
  ) ) && $current_modal == "3" ? true : false;
12
+ $configured_2FA_method = $Mo2fdbQueries->get_user_detail( 'mo2f_configured_2FA_method', $user->ID );
13
  $twoFA_method_to_configure = get_user_meta( $user->ID, 'mo2f_2FA_method_to_configure', true );
14
  $mo2f_message = get_option( 'mo2f_message' );
15
  ?>
views/configure_otp_over_sms CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
 
3
  function mo2f_configure_otp_over_sms( $user ) {
4
- global $dbQueries;
5
- $mo2f_user_phone = $dbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
6
  $user_phone = isset( $_SESSION['user_phone'] ) && $_SESSION['user_phone'] != 'false' ? $_SESSION['user_phone'] : $mo2f_user_phone ?
7
  $mo2f_user_phone : get_option( 'user_phone_temp' );
8
  ?>
1
  <?php
2
 
3
  function mo2f_configure_otp_over_sms( $user ) {
4
+ global $Mo2fdbQueries;
5
+ $mo2f_user_phone = $Mo2fdbQueries->get_user_detail( 'mo2f_user_phone', $user->ID );
6
  $user_phone = isset( $_SESSION['user_phone'] ) && $_SESSION['user_phone'] != 'false' ? $_SESSION['user_phone'] : $mo2f_user_phone ?
7
  $mo2f_user_phone : get_option( 'user_phone_temp' );
8
  ?>