first commit
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
|
||||
/**
|
||||
* @var \WordfenceLS\Model_2faInitializationData $initializationData The initialization data for setting up 2FA for a specific user. Required.
|
||||
*/
|
||||
$user = $initializationData->get_user();
|
||||
$recovery = $initializationData->get_recovery_codes();
|
||||
?>
|
||||
<div class="wfls-block wfls-always-active wfls-flex-item-full-width">
|
||||
<div class="wfls-block-header wfls-block-header-border-bottom">
|
||||
<div class="wfls-block-header-content">
|
||||
<div class="wfls-block-title">
|
||||
<strong><?php esc_html_e('2. Enter Code from Authenticator App', 'wordfence-2fa'); ?></strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wfls-block-content wfls-padding-add-bottom">
|
||||
<p><?php esc_html_e('Download Recovery Codes', 'wordfence-2fa'); ?> <em class="wfls-text-small"><?php esc_html_e('Optional', 'wordfence-2fa'); ?></em></p>
|
||||
<p><?php echo esc_html(sprintf(__('Use one of these %d codes to log in if you lose access to your authenticator device. Codes are %d characters long plus optional spaces. Each one may be used only once.', 'wordfence-2fa'), count($recovery), \WordfenceLS\Model_Crypto::strlen($recovery[0]) * 2)); ?></p>
|
||||
<ul class="wfls-recovery-codes">
|
||||
<?php
|
||||
$recoveryCodeFileContents = sprintf(__('Two-Factor Authentication Recovery Codes - %s (%s)', 'wordfence-2fa'), home_url(), $user->user_login) . "\r\n";
|
||||
$recoveryCodeFileContents .= "\r\n" . sprintf(__('Each line of %d letters and numbers is a single recovery code, with optional spaces for readability. To use a recovery code, after entering your username and password, enter the code like "1234 5678 90AB CDEF" at the 2FA prompt. If your site has a custom login prompt and does not show a 2FA prompt, you can use the single-step method by entering your password and the code together in the Password field, like "mypassword1234 5678 90AB CDEF". Your recovery codes are:', 'wordfence-2fa'), \WordfenceLS\Model_Crypto::strlen($recovery[0]) * 2) . "\r\n\r\n";
|
||||
foreach ($recovery as $c) {
|
||||
$hex = bin2hex($c);
|
||||
$blocks = str_split($hex, 4);
|
||||
echo '<li>' . implode(' ', $blocks) . '</li>';
|
||||
$recoveryCodeFileContents .= implode(' ', $blocks) . "\r\n";
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
<p class="wfls-center"><a href="#" class="wfls-btn wfls-btn-default" id="wfls-recovery-download" target="_blank" rel="noopener noreferrer"><i class="dashicons dashicons-download"></i> <?php esc_html_e('Download', 'wordfence-2fa'); ?></a></p>
|
||||
|
||||
<hr class="wfls-half">
|
||||
|
||||
<p><?php esc_html_e('Enter the code from your authenticator app below to verify and activate two-factor authentication for this account.', 'wordfence-2fa'); ?></p>
|
||||
<p><input type="text" id="wfls-activate-field" value="" size="6" maxlength="6" placeholder="123456" autocomplete="off"></p>
|
||||
</div>
|
||||
<div class="wfls-block-footer">
|
||||
<div class="wfls-block-footer-content">
|
||||
<div class="wfls-block-title" id="wfls-activation-help-link-container">
|
||||
<a href="<?php echo \WordfenceLS\Controller_Support::esc_supportURL(\WordfenceLS\Controller_Support::ITEM_MODULE_LOGIN_SECURITY_2FA); ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e('For help on setting up an app, visit our help article.', 'wordfence-2fa'); ?></a>
|
||||
</div>
|
||||
<div class="wfls-block-footer-action"><a href="#" id="wfls-activate" class="wfls-btn wfls-btn-default wfls-disabled"><?php esc_html_e('Activate', 'wordfence-2fa'); ?></a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="application/javascript">
|
||||
(function($) {
|
||||
$(function() {
|
||||
$('#wfls-activate-field').on('keyup', function(e) {
|
||||
$('#wfls-activate').toggleClass('wfls-disabled', $('#wfls-activate-field').val().length != 6);
|
||||
|
||||
if (e.keyCode == 13) {
|
||||
$('#wfls-activate').trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
$('#wfls-recovery-download').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
saveAs(new Blob(["<?php echo str_replace("\n", "\\n", str_replace("\r", "\\r", addslashes($recoveryCodeFileContents))); ?>"], {type: "text/plain;charset=" + document.characterSet}), '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(preg_replace('~^https?://~i', '', home_url())) . '_' . \WordfenceLS\Text\Model_JavaScript::esc_js($user->user_login) . '_recoverycodes.txt'; ?>');
|
||||
WFLS.savedRecoveryCodes = true;
|
||||
});
|
||||
|
||||
$('#wfls-activate').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
if (WFLS.userIsActivating) { //Likely a double-click
|
||||
return;
|
||||
}
|
||||
|
||||
WFLS.userIsActivating = true;
|
||||
|
||||
var payload = {
|
||||
secret: '<?php echo bin2hex($initializationData->get_raw_secret()); ?>',
|
||||
recovery: ['<?php echo implode('\', \'', array_map(function($c) { return bin2hex($c); }, $recovery)); ?>'],
|
||||
code: $('#wfls-activate-field').val(),
|
||||
user: <?php echo $user->ID; ?>,
|
||||
};
|
||||
|
||||
WFLS.ajax(
|
||||
'wordfence_ls_activate',
|
||||
payload,
|
||||
function(response) {
|
||||
if (response.error) {
|
||||
WFLS.panelModal((WFLS.screenSize(500) ? '300px' : '400px'), '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('Error Activating 2FA', 'wordfence-2fa')); ?>', response.error);
|
||||
}
|
||||
else {
|
||||
$('#wfls-activation-controls').crossfade($('#wfls-deactivation-controls'));
|
||||
$('#wfls-recovery-code-count').text(response.text);
|
||||
$('#wfls-activate-field').val('');
|
||||
|
||||
$('.wfls-notice[data-notice-type="wfls-will-be-required"]').find('.wfls-dismiss-link').trigger('click');
|
||||
|
||||
if (!WFLS.savedRecoveryCodes) {
|
||||
var prompt = $('#wfls-tmpl-recovery-skipped-prompt').tmpl({});
|
||||
var promptHTML = $("<div />").append(prompt).html();
|
||||
WFLS.panelHTML((WFLS.screenSize(500) ? '300px' : '400px'), promptHTML, { fixed: true, overlayClose: false, closeButton: false, className: 'wfls-modal', onComplete: function() {
|
||||
$('#wfls-recovery-skipped-download').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
saveAs(new Blob(["<?php echo str_replace("\n", "\\n", str_replace("\r", "\\r", addslashes($recoveryCodeFileContents))); ?>"], {type: "text/plain;charset=" + document.characterSet}), '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(preg_replace('~^https?://~i', '', home_url())) . '_' . \WordfenceLS\Text\Model_JavaScript::esc_js($user->user_login) . '_recoverycodes.txt'; ?>');
|
||||
WFLS.panelClose();
|
||||
});
|
||||
$('#wfls-recovery-skipped-skip').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
WFLS.panelClose();
|
||||
});
|
||||
}});
|
||||
}
|
||||
WFLS.savedRecoveryCodes = false;
|
||||
WFLS.userIsActivating = false;
|
||||
}
|
||||
},
|
||||
function(error) {
|
||||
WFLS.panelModal((WFLS.screenSize(500) ? '300px' : '400px'), '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('Error Activating 2FA', 'wordfence-2fa')); ?>', '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('An error was encountered while trying to activate two-factor authentication. Please try again.', 'wordfence-2fa')); ?>');
|
||||
WFLS.userIsActivating = false;
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
</script>
|
||||
<script type="text/x-jquery-template" id="wfls-tmpl-recovery-skipped-prompt">
|
||||
<?php
|
||||
echo \WordfenceLS\Model_View::create('common/modal-prompt', array(
|
||||
'title' => __('Download Recovery Codes', 'wordfence-2fa'),
|
||||
'message' => __('Reminder: If you lose access to your authenticator device, you can use recovery codes to log in. If you have not saved a copy of your recovery codes, we recommend downloading them now.', 'wordfence-2fa'),
|
||||
'primaryButton' => array('id' => 'wfls-recovery-skipped-download', 'label' => __('Download', 'wordfence-2fa'), 'link' => '#'),
|
||||
'secondaryButtons' => array(array('id' => 'wfls-recovery-skipped-skip', 'label' => __('Skip', 'wordfence-2fa'), 'link' => '#')),
|
||||
))->render();
|
||||
?>
|
||||
</script>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
|
||||
/**
|
||||
* @var \WordfenceLS\Model_2faInitializationData $initializationData The initialization data for setting up 2FA for a specific user. Required.
|
||||
*/
|
||||
?>
|
||||
<div class="wfls-block wfls-always-active wfls-flex-item-full-width">
|
||||
<div class="wfls-block-header wfls-block-header-border-bottom">
|
||||
<div class="wfls-block-header-content">
|
||||
<div class="wfls-block-title">
|
||||
<strong><?php esc_html_e('1. Scan Code or Enter Key', 'wordfence-2fa'); ?></strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wfls-block-content wfls-padding-add-bottom">
|
||||
<p>Scan the code below with your authenticator app to add this account. Some authenticator apps also allow you to type in the text version instead.</p>
|
||||
<div id="wfls-qr-code"></div>
|
||||
<p class="wfls-center wfls-no-bottom"><input id="wfls-qr-code-text" class="wfls-center" type="text" value="<?php echo esc_attr($initializationData->get_base32_secret()); ?>" onclick="this.select();" size="32" readonly></p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="application/javascript">
|
||||
(function($) {
|
||||
$(function() {
|
||||
var narrowPreviously = null;
|
||||
function renderQrCode() {
|
||||
var narrow = WFLS.screenSize(500);
|
||||
if (narrow !== narrowPreviously) {
|
||||
$('#wfls-qr-code').empty().qrcode({text: '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js($initializationData->get_otp_url()); ?>', width: (narrow ? 175 : 256), height: (narrow ? 175 : 256)});
|
||||
$('#wfls-qr-code-text').css('font-family', narrow ? '' : 'monospace');
|
||||
}
|
||||
narrowPreviously = narrow;
|
||||
}
|
||||
$(window).on('resize', renderQrCode);
|
||||
renderQrCode();
|
||||
});
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
|
||||
/**
|
||||
* @var \WP_User $user The user being edited. Required.
|
||||
*/
|
||||
|
||||
$ownAccount = false;
|
||||
$ownUser = wp_get_current_user();
|
||||
if ($ownUser->ID == $user->ID) {
|
||||
$ownAccount = true;
|
||||
}
|
||||
?>
|
||||
<div class="wfls-block wfls-always-active wfls-flex-item-full-width">
|
||||
<div class="wfls-block-header wfls-block-header-border-bottom">
|
||||
<div class="wfls-block-header-content">
|
||||
<div class="wfls-block-title">
|
||||
<strong><?php esc_html_e('Wordfence 2FA Active', 'wordfence-2fa'); ?></strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wfls-block-content wfls-padding-add-bottom">
|
||||
<p><?php if ($ownAccount) { esc_html_e('Wordfence two-factor authentication is currently active on your account. You may deactivate it by clicking the button below.', 'wordfence-2fa'); } else { echo wp_kses(sprintf(__('Wordfence two-factor authentication is currently active on the account <strong>%s</strong>. You may deactivate it by clicking the button below.', 'wordfence-2fa'), esc_html($user->user_login)), array('strong'=>array())); } ?></p>
|
||||
<p class="wfls-center wfls-add-top"><a href="#" class="wfls-btn wfls-btn-default" id="wfls-deactivate" target="_blank" rel="noopener noreferrer"><?php esc_html_e('Deactivate', 'wordfence-2fa'); ?></a></p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/x-jquery-template" id="wfls-tmpl-deactivate-prompt">
|
||||
<?php
|
||||
echo \WordfenceLS\Model_View::create('common/modal-prompt', array(
|
||||
'title' => __('Deactivate 2FA', 'wordfence-2fa'),
|
||||
'message' => __('Are you sure you want to deactivate two-factor authentication?', 'wordfence-2fa'),
|
||||
'primaryButton' => array('id' => 'wfls-deactivate-prompt-cancel', 'label' => __('Cancel', 'wordfence-2fa'), 'link' => '#'),
|
||||
'secondaryButtons' => array(array('id' => 'wfls-deactivate-prompt-confirm', 'label' => __('Deactivate', 'wordfence-2fa'), 'link' => '#')),
|
||||
))->render();
|
||||
?>
|
||||
</script>
|
||||
<script type="application/javascript">
|
||||
(function($) {
|
||||
$(function() {
|
||||
$('#wfls-deactivate').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
var prompt = $('#wfls-tmpl-deactivate-prompt').tmpl({});
|
||||
var promptHTML = $("<div />").append(prompt).html();
|
||||
WFLS.panelHTML((WFLS.screenSize(500) ? '300px' : '400px'), promptHTML, {overlayClose: false, closeButton: false, className: 'wfls-modal', onComplete: function() {
|
||||
$('#wfls-deactivate-prompt-cancel').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
WFLS.panelClose();
|
||||
});
|
||||
|
||||
$('#wfls-deactivate-prompt-confirm').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
var payload = {
|
||||
user: <?php echo (int) $user->ID; ?>,
|
||||
};
|
||||
|
||||
WFLS.ajax(
|
||||
'wordfence_ls_deactivate',
|
||||
payload,
|
||||
function(response) {
|
||||
if (response.error) {
|
||||
WFLS.panelModal((WFLS.screenSize(500) ? '300px' : '400px'), '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('Error Deactivating 2FA', 'wordfence-2fa')); ?>', response.error);
|
||||
}
|
||||
else {
|
||||
$('#wfls-deactivation-controls').crossfade($('#wfls-activation-controls'));
|
||||
}
|
||||
|
||||
WFLS.panelClose(); //The prompt
|
||||
},
|
||||
function(error) {
|
||||
WFLS.panelModal((WFLS.screenSize(500) ? '300px' : '400px'), '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('Error Deactivating 2FA', 'wordfence-2fa')); ?>', '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('An error was encountered while trying to deactivate two-factor authentication. Please try again.', 'wordfence-2fa')); ?>');
|
||||
WFLS.panelClose(); //The prompt
|
||||
}
|
||||
);
|
||||
});
|
||||
}});
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
|
||||
/**
|
||||
* @var \WP_User $user The user being edited. Required.
|
||||
* @var bool $inGracePeriod
|
||||
* @var bool $lockedOut
|
||||
* @var int $requiredAt
|
||||
*/
|
||||
|
||||
$ownAccount = false;
|
||||
$ownUser = wp_get_current_user();
|
||||
if ($ownUser->ID == $user->ID) {
|
||||
$ownAccount = true;
|
||||
}
|
||||
$defaultGracePeriod = \WordfenceLS\Controller_Settings::shared()->get_user_2fa_grace_period();
|
||||
$hasGracePeriod = $defaultGracePeriod > 0;
|
||||
?>
|
||||
<div class="wfls-block wfls-always-active wfls-flex-item-full-width">
|
||||
<div class="wfls-block-header wfls-block-header-border-bottom">
|
||||
<div class="wfls-block-header-content">
|
||||
<div class="wfls-block-title">
|
||||
<strong><?php echo $gracePeriod ? esc_html__('Grace Period', 'wordfence-2fa') : esc_html__('Locked Out', 'wordfence-2fa') ?></strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wfls-block-content">
|
||||
<?php if ($gracePeriod): ?>
|
||||
<p><?php
|
||||
$requiredDateFormatted = \WordfenceLS\Controller_Time::format_local_time('F j, Y g:i A', $requiredAt);
|
||||
echo $ownAccount ?
|
||||
sprintf(wp_kses(__('Two-factor authentication will be required for your account beginning <strong>%s</strong>', 'wordfence-2fa'), array('strong'=>array())), $requiredDateFormatted) :
|
||||
sprintf(wp_kses(__('Two-factor authentication will be required for user <strong>%s</strong> beginning <strong>%s</strong>.', 'wordfence-2fa'), array('strong'=>array())), esc_html($user->user_login), $requiredDateFormatted)
|
||||
?></p>
|
||||
<?php if (\WordfenceLS\Controller_Users::shared()->has_revokable_grace_period($user)): ?>
|
||||
<?php echo \WordfenceLS\Model_View::create(
|
||||
'common/revoke-grace-period',
|
||||
array(
|
||||
'user' => $user
|
||||
))->render() ?>
|
||||
<?php endif ?>
|
||||
<?php else: ?>
|
||||
<p>
|
||||
<?php echo $ownAccount ?
|
||||
esc_html__('Two-factor authentication is required for your account, but has not been configured.', 'wordfence-2fa') :
|
||||
esc_html__('Two-factor authentication is required for this account, but has not been configured.', 'wordfence-2fa') ?>
|
||||
</p>
|
||||
<?php echo \WordfenceLS\Model_View::create(
|
||||
'common/reset-grace-period',
|
||||
array(
|
||||
'user' => $user,
|
||||
'gracePeriod' => $gracePeriod,
|
||||
'defaultGracePeriod' => $defaultGracePeriod
|
||||
))->render() ?>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
|
||||
/**
|
||||
* @var \WP_User $user The user being edited. Required.
|
||||
* @var int $remaining The number of unused recovery codes. Required.
|
||||
*/
|
||||
?>
|
||||
<div class="wfls-block wfls-always-active wfls-flex-item-full-width">
|
||||
<div class="wfls-block-header wfls-block-header-border-bottom">
|
||||
<div class="wfls-block-header-content">
|
||||
<div class="wfls-block-title">
|
||||
<strong><?php esc_html_e('Recovery Codes', 'wordfence-2fa'); ?></strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wfls-block-content wfls-padding-add-bottom">
|
||||
<p id="wfls-recovery-code-count"><?php echo esc_html(sprintf($remaining == 1 ? __('%d unused recovery code remains. You may generate a new set by clicking below.', 'wordfence-2fa') : __('%d unused recovery codes remain. You may generate a new set by clicking below.', 'wordfence-2fa'), $remaining)); ?></p>
|
||||
<p class="wfls-center wfls-add-top"><a href="#" class="wfls-btn wfls-btn-default" id="wfls-recovery" target="_blank" rel="noopener noreferrer"><?php esc_html_e('Generate New Codes', 'wordfence-2fa'); ?></a></p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/x-jquery-template" id="wfls-tmpl-recovery-prompt">
|
||||
<?php
|
||||
echo \WordfenceLS\Model_View::create('common/modal-prompt', array(
|
||||
'title' => __('Generate New Recovery Codes', 'wordfence-2fa'),
|
||||
'message' => __('Are you sure you want to generate new recovery codes? Any remaining unused codes will be disabled.', 'wordfence-2fa'),
|
||||
'primaryButton' => array('id' => 'wfls-recovery-prompt-cancel', 'label' => __('Cancel', 'wordfence-2fa'), 'link' => '#'),
|
||||
'secondaryButtons' => array(array('id' => 'wfls-recovery-prompt-confirm', 'label' => __('Generate', 'wordfence-2fa'), 'link' => '#')),
|
||||
))->render();
|
||||
?>
|
||||
</script>
|
||||
<script type="application/javascript">
|
||||
(function($) {
|
||||
$(function() {
|
||||
$('#wfls-recovery').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
var prompt = $('#wfls-tmpl-recovery-prompt').tmpl({});
|
||||
var promptHTML = $("<div />").append(prompt).html();
|
||||
WFLS.panelHTML((WFLS.screenSize(500) ? '300px' : '400px'), promptHTML, {overlayClose: false, closeButton: false, className: 'wfls-modal', onComplete: function() {
|
||||
$('#wfls-recovery-prompt-cancel').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
WFLS.panelClose();
|
||||
});
|
||||
|
||||
$('#wfls-recovery-prompt-confirm').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
var payload = {
|
||||
user: <?php echo (int) $user->ID; ?>,
|
||||
};
|
||||
|
||||
WFLS.ajax(
|
||||
'wordfence_ls_regenerate',
|
||||
payload,
|
||||
function(response) {
|
||||
if (response.error) {
|
||||
WFLS.panelModal((WFLS.screenSize(500) ? '300px' : '400px'), '<?php echo esc_js(__('Error Generating New Codes', 'wordfence-2fa')); ?>', response.error);
|
||||
}
|
||||
else if (response.recovery) {
|
||||
$('#wfls-recovery-code-count').text(response.text);
|
||||
|
||||
var message = '<p><?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(sprintf(__('Use one of these %d codes to log in if you lose access to your authenticator device. Codes are %d characters long plus optional spaces. Each one may be used only once.', 'wordfence-2fa'), \WordfenceLS\Controller_Users::RECOVERY_CODE_COUNT, \WordfenceLS\Controller_Users::RECOVERY_CODE_SIZE * 2)); ?></p><ul class="wfls-recovery-codes">';
|
||||
|
||||
var recoveryCodeFileContents = '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(sprintf(__('Two-Factor Authentication Recovery Codes - %s (%s)', 'wordfence-2fa'), preg_replace('~^https?://~i', '', home_url()), $user->user_login)); ?>' + "\r\n";
|
||||
recoveryCodeFileContents = recoveryCodeFileContents + "\r\n" + '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(sprintf(__('Each line of %d letters and numbers is a single recovery code, with optional spaces for readability. To use a recovery code, after entering your username and password, enter the code like "1234 5678 90AB CDEF" at the 2FA prompt. If your site has a custom login prompt and does not show a 2FA prompt, you can use the single-step method by entering your password and the code together in the Password field, like "mypassword1234 5678 90AB CDEF". Your recovery codes are:', 'wordfence-2fa'), \WordfenceLS\Controller_Users::RECOVERY_CODE_SIZE * 2)); ?>' + "\r\n\r\n";
|
||||
for (var i = 0; i < response.recovery.length; i++) {
|
||||
message = message + '<li>' + response.recovery[i] + '</li>';
|
||||
recoveryCodeFileContents = recoveryCodeFileContents + response.recovery[i] + "\r\n";
|
||||
}
|
||||
|
||||
message = message + "</ul>";
|
||||
|
||||
message = message + "<p class=\"wfls-center\"><a href=\"#\" class=\"wfls-btn wfls-btn-default\" id=\"wfls-recovery-new-download\" target=\"_blank\" rel=\"noopener noreferrer\"><i class=\"dashicons dashicons-download\"></i> <?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('Download', 'wordfence-2fa')); ?></a></p>";
|
||||
|
||||
|
||||
WFLS.panelModalHTML((WFLS.screenSize(500) ? '300px' : '400px'), "<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('New Recovery Codes', 'wordfence-2fa')); ?>", message, {onComplete: function() {
|
||||
$('#wfls-recovery-new-download').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
saveAs(new Blob([recoveryCodeFileContents], {type: "text/plain;charset=" + document.characterSet}), '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(preg_replace('~^https?://~i', '', home_url()) . '_' . $user->user_login . '_recoverycodes.txt'); ?>');
|
||||
});
|
||||
}});
|
||||
}
|
||||
|
||||
WFLS.panelClose(); //The prompt
|
||||
},
|
||||
function(error) {
|
||||
WFLS.panelModal((WFLS.screenSize(500) ? '300px' : '400px'), '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('Error Generating New Codes', 'wordfence-2fa')); ?>', '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('An error was encountered while trying to generate new recovery codes. Please try again.', 'wordfence-2fa')); ?>');
|
||||
WFLS.panelClose(); //The prompt
|
||||
}
|
||||
);
|
||||
});
|
||||
}});
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
</script>
|
||||
Reference in New Issue
Block a user