function mo2f_create_user($current_user, $email) { $email = strtolower($email); $enduser = new Two_Factor_Setup(); $check_user = json_decode($enduser->mo_check_user_already_exist($email), true); if (json_last_error() == JSON_ERROR_NONE) { if ($check_user['status'] == 'ERROR') { update_option('mo2f_message', $check_user['message']); $this->mo_auth_show_error_message(); } else { if (strcasecmp($check_user['status'], 'USER_FOUND') == 0) { delete_user_meta($current_user->ID, 'mo_2factor_user_email'); update_user_meta($current_user->ID, 'mo_2factor_user_registration_with_miniorange', 'SUCCESS'); update_user_meta($current_user->ID, 'mo_2factor_map_id_with_email', $email); update_user_meta($current_user->ID, 'mo_2factor_user_registration_status', 'MO_2_FACTOR_PLUGIN_SETTINGS'); $enduser->mo2f_update_userinfo(get_user_meta($current_user->ID, 'mo_2factor_map_id_with_email', true), 'OUT OF BAND EMAIL', null, 'API_2FA', true); update_user_meta($current_user->ID, 'mo2f_email_verification_status', true); $message = 'You are registered successfully. <b>Email Verification</b> has been set as your default 2nd factor method. <a href=\\"admin.php?page=miniOrange_2_factor_settings&mo2f_tab=mobile_configure\\" >Click Here </a>to configure another 2nd factor authentication method.'; update_option('mo2f_message', $message); $this->mo_auth_show_success_message(); } else { if (strcasecmp($check_user['status'], 'USER_NOT_FOUND') == 0) { $content = json_decode($enduser->mo_create_user($current_user, $email), true); if (json_last_error() == JSON_ERROR_NONE) { if ($content['status'] == 'ERROR') { update_option('mo2f_message', $content['message']); $this->mo_auth_show_error_message(); } else { if (strcasecmp($content['status'], 'SUCCESS') == 0) { delete_user_meta($current_user->ID, 'mo_2factor_user_email'); update_user_meta($current_user->ID, 'mo_2factor_user_registration_with_miniorange', 'SUCCESS'); update_user_meta($current_user->ID, 'mo_2factor_map_id_with_email', $email); update_user_meta($current_user->ID, 'mo_2factor_user_registration_status', 'MO_2_FACTOR_PLUGIN_SETTINGS'); $enduser->mo2f_update_userinfo(get_user_meta($current_user->ID, 'mo_2factor_map_id_with_email', true), 'OUT OF BAND EMAIL', null, 'API_2FA', true); update_user_meta($current_user->ID, 'mo2f_email_verification_status', true); $message = 'You are registered successfully. <b>Email Verification</b> has been set as your default 2nd factor method. <a href=\\"admin.php?page=miniOrange_2_factor_settings&mo2f_tab=mobile_configure\\" >Click Here </a>to configure another 2nd factor authentication method.'; update_option('mo2f_message', $message); $this->mo_auth_show_success_message(); } else { update_option('mo2f_message', 'Error occurred while registering the user. Please try again.'); $this->mo_auth_show_error_message(); } } } else { update_option('mo2f_message', 'Error occurred while registering the user. Please try again or contact your admin.'); $this->mo_auth_show_error_message(); } } else { update_option('mo2f_message', 'Error occurred while registering the user. Please try again.'); $this->mo_auth_show_error_message(); } } } } else { update_option('mo2f_message', 'Error occurred while registering the user. Please try again.'); $this->mo_auth_show_error_message(); } }
function mo2f_register_user_inline($email) { $enduser = new Two_Factor_Setup(); $check_user = json_decode($enduser->mo_check_user_already_exist($email), true); $currentUserId = $_SESSION['mo2f_current_user']->ID; $current_user = $_SESSION['mo2f_current_user']; if (json_last_error() == JSON_ERROR_NONE) { if ($check_user['status'] == 'ERROR') { $_SESSION['mo2f-login-message'] = $check_user['message']; } else { if (strcasecmp($check_user['status'], 'USER_FOUND') == 0) { delete_user_meta($currentUserId, 'mo_2factor_user_email'); update_user_meta($currentUserId, 'mo_2factor_user_registration_with_miniorange', 'SUCCESS'); update_user_meta($currentUserId, 'mo_2factor_map_id_with_email', $email); update_user_meta($currentUserId, 'mo_2factor_user_registration_status', 'MO_2_FACTOR_INITIALIZE_TWO_FACTOR'); $_SESSION['mo_2factor_login_status'] = 'MO_2_FACTOR_PROMPT_USER_FOR_2FA_METHODS'; $message = ''; $_SESSION['mo2f-login-message'] = $message; } else { if (strcasecmp($check_user['status'], 'USER_NOT_FOUND') == 0) { $content = json_decode($enduser->mo_create_user($current_user, $email), true); if (json_last_error() == JSON_ERROR_NONE) { if ($content['status'] == 'ERROR') { $_SESSION['mo2f-login-message'] = $content['message']; } else { if (strcasecmp($content['status'], 'SUCCESS') == 0) { delete_user_meta($currentUserId, 'mo_2factor_user_email'); update_user_meta($currentUserId, 'mo_2factor_user_registration_with_miniorange', 'SUCCESS'); update_user_meta($currentUserId, 'mo_2factor_map_id_with_email', $email); update_user_meta($currentUserId, 'mo_2factor_user_registration_status', 'MO_2_FACTOR_INITIALIZE_TWO_FACTOR'); $enduser->mo2f_update_userinfo(get_user_meta($currentUserId, 'mo_2factor_map_id_with_email', true), 'OUT OF BAND EMAIL', null, null, null); $message = ''; $_SESSION['mo2f-login-message'] = $message; $_SESSION['mo_2factor_login_status'] = 'MO_2_FACTOR_PROMPT_USER_FOR_2FA_METHODS'; } else { $_SESSION['mo2f-login-message'] = 'Error occurred while registering the user. Please try again.'; } } } else { $_SESSION['mo2f-login-message'] = 'Error occurred while registering the user. Please try again or contact your admin.'; } } else { $_SESSION['mo2f-login-message'] = 'Error occurred while registering the user. Please try again.'; } } } } else { $_SESSION['mo2f-login-message'] = 'Error occurred while registering the user. Please try again.'; } }