PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.74
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.74
1.2.74 1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 All 174 releases
← All changes | assets/js/users-wp.js +103 -1 1.2.681.2.74 View file →
@@ -932,5 +932,107 @@
932 932 return true;
933 933 } else {
934 934 return false;
935 935 }
936 -}
936 +}
937 +
938 +/**
939 + * Use the same two-step AJAX login flow on an in-page form as the login modal.
940 + * This lets Wordfence validate the password first and return a separate 2FA form.
941 + */
942 +(function ($) {
943 + $(document).ready(function () {
944 + if (!uwp_localize_data.wordfence_2fa_active) {
945 + return;
946 + }
947 +
948 + $('form.uwp-login-form').each(function () {
949 + var $form = $(this);
950 +
951 + if ($form.closest('#uwp_login_modal, .uwp-auth-modal').length) {
952 + return;
953 + }
954 +
955 + $form.on('submit.uwpPageLogin', function (e) {
956 + e.preventDefault();
957 + uwp_page_login_process($form);
958 + });
959 + });
960 + });
961 +
962 + function uwp_page_login_process($form) {
963 + var $submit = $form.find('.uwp_login_submit');
964 + var buttonText = $submit.html();
965 +
966 + $form.prev('.alert').remove();
967 + $submit.prop('disabled', true);
968 +
969 + $.post(uwp_localize_data.ajaxurl, $form.serialize() + '&action=uwp_ajax_login', function (response) {
970 + if (typeof response === 'string') {
971 + response = $.parseJSON(response);
972 + }
973 +
974 + if (response.success === true && response.data && response.data.is_2fa) {
975 + var $twoFactorMarkup = $(response.data.html);
976 + var $twoFactorForm = $twoFactorMarkup.filter('form.validate_2fa_form')
977 + .add($twoFactorMarkup.find('form.validate_2fa_form')).first();
978 +
979 + $form.replaceWith($twoFactorMarkup);
980 + bind_2fa_form($twoFactorForm);
981 + $twoFactorForm.find('input:visible:enabled:first').trigger('focus');
982 + return;
983 + }
984 +
985 + if (response.success === true) {
986 + if (response.data && response.data.message) {
987 + $form.before(response.data.message);
988 + }
989 + window.setTimeout(function () {
990 + if (response.data && response.data.redirect) {
991 + window.location.href = response.data.redirect;
992 + } else {
993 + window.location.reload();
994 + }
995 + }, 1000);
996 + return;
997 + }
998 +
999 + $form.before(response.data && response.data.message ? response.data.message : response.message);
1000 + $submit.html(buttonText).prop('disabled', false);
1001 + document.dispatchEvent(new Event('ayecode_reset_captcha'));
1002 + }).fail(function () {
1003 + $submit.html(buttonText).prop('disabled', false);
1004 + });
1005 + }
1006 +
1007 + function bind_2fa_form($form) {
1008 + $form.on('submit.uwpPageLogin2fa', function (e) {
1009 + e.preventDefault();
1010 +
1011 + var $submit = $form.find('.uwp-2fa-submit');
1012 + $form.prev('.alert').remove();
1013 + $submit.prop('disabled', true);
1014 +
1015 + $.post(uwp_localize_data.ajaxurl, $form.serialize() + '&action=uwp_ajax_login_process_2fa', function (response) {
1016 + if (typeof response === 'string') {
1017 + response = $.parseJSON(response);
1018 + }
1019 +
1020 + $form.before(response.data && response.data.message ? response.data.message : response.message);
1021 +
1022 + if (response.success === true) {
1023 + window.setTimeout(function () {
1024 + if (response.data && response.data.redirect) {
1025 + window.location.href = response.data.redirect;
1026 + } else {
1027 + window.location.reload();
1028 + }
1029 + }, 1000);
1030 + } else {
1031 + $submit.prop('disabled', false);
1032 + }
1033 + }).fail(function () {
1034 + $submit.prop('disabled', false);
1035 + });
1036 + });
1037 + }
1038 +})(jQuery);