PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.3.1
Defender Security – Malware Scanner, Login Security & Firewall v5.3.1
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / src / view / two-fa / providers / totp-disabled.php

totp-disabled.php in Defender Security – Malware Scanner, Login Security & Firewall 5.3.1, at src/view/two-fa/providers/totp-disabled.php

162 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * This template is used to display Authenticator App for 2FA.
4 *
5 * @package WP_Defender
6 */
7
8 ?>
9 <div id="defender-totp" class="<?php echo esc_attr( $class ); ?>">
10 <div class="card">
11 <strong>
12 <?php esc_attr_e( '1. Install the Verification app', 'defender-security' ); ?>
13 </strong>
14 <p>
15 <?php
16 esc_attr_e( 'Download and install the authenticator app on your device using the links below.', 'defender-security' );
17 ?>
18 <select id="auth-app">
19 <?php
20 foreach ( $auth_apps as $key => $app ) {
21 ?>
22 <option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_attr( $app ); ?></option>
23 <?php } ?>
24 </select>
25 </p>
26 <a id="ios-app" target="_blank" href="https://itunes.apple.com/vn/app/google-authenticator/id388497605?mt=8">
27 <img src="<?php defender_asset_url( '/assets/img/ios-download.svg', true ); ?>"/>
28 </a>
29 <a id="android-app" target="_blank"
30 href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2">
31 <img src="<?php defender_asset_url( '/assets/img/android-download.svg', true ); ?> "/>
32 </a>
33 <div class="line"></div>
34 <strong>
35 <?php esc_attr_e( '2. Scan the QR code or enter the key', 'defender-security' ); ?>
36 </strong>
37 <?php if ( $is_success ) { ?>
38 <p class="wd_text_wrap">
39 <?php
40 esc_attr_e(
41 'Open the authenticator app, and scan the QR code below or manually enter the setup key to add your new site.',
42 'defender-security'
43 )
44 ?>
45 </p>
46 <div id="defender-qr-code"></div>
47 <p class="wd_code_wrap">
48 <code id="wd_clipboard"><?php echo esc_html( $secret_key ); ?></code>
49 <button type="button" class="button" id="wd_copy_2fa_key"
50 data-clipborad-action="copy" data-clipboard-target="#wd_clipboard">
51 <?php esc_attr_e( 'Copy', 'defender-security' ); ?>
52 </button>
53 </p>
54 <?php } else { ?>
55 <p class="error_process"><?php echo esc_html( $secret_key ); ?></p>
56 <?php } ?>
57 <div class="line"></div>
58 <strong>
59 <?php esc_attr_e( '3. Enter passcode', 'defender-security' ); ?>
60 </strong>
61 <p>
62 <?php
63 esc_attr_e(
64 'Enter the 6 digit passcode that is shown on your device into the input field below and hit "Verify".',
65 'defender-security'
66 )
67 ?>
68 </p>
69 <div class="well" style="width: auto;">
70 <p class="error"></p>
71 <input type="text" id="otp-code" class="def-small-text"
72 placeholder="<?php esc_attr_e( 'Enter passcode', 'defender-security' ); ?>"/>
73 <button type="button"
74 class="button button-primary" <?php echo $is_success ? 'id="verify-otp"' : 'disabled'; ?>>
75 <?php esc_attr_e( 'Verify', 'defender-security' ); ?>
76 </button>
77 </div>
78 </div>
79 </div>
80 <script type="text/javascript">
81 jQuery(function ($) {
82 // Copy/past the key.
83 new ClipboardJS('#wd_copy_2fa_key');
84 // Toggle.
85 $('body').on('click', '#field-totp', function () {
86 $('#defender-totp').toggle();
87 });
88
89 var links = {
90 'google-authenticator': {
91 android: 'https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2',
92 ios: 'https://apps.apple.com/app/google-authenticator/id388497605'
93 },
94 'microsoft-authenticator': {
95 android: 'https://play.google.com/store/apps/details?id=com.azure.authenticator',
96 ios: 'https://apps.apple.com/app/microsoft-authenticator/id983156458'
97 },
98 'authy': {
99 android: 'https://play.google.com/store/apps/details?id=com.authy.authy',
100 ios: 'https://apps.apple.com/app/authy/id494168017'
101 }
102 };
103 $('body').on('change', '#auth-app', function () {
104 var value = $(this).val();
105 var app = links[value];
106 if (typeof app !== 'undefined') {
107 $('#android-app').attr('href', app.android);
108 $('#ios-app').attr('href', app.ios)
109 }
110 })
111
112 function verifyOtp(el) {
113 var data = {
114 data: JSON.stringify({
115 otp: $('#otp-code').val(),
116 setup_key: $('#wd_clipboard').html(),
117 })
118 }
119 $.ajax({
120 type: 'POST',
121 url: '<?php echo $url; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>',
122 data: data,
123 beforeSend: function () {
124 el.attr('disabled', 'disabled');
125 },
126 success: function (data) {
127 if (data.success == true) {
128 location.reload();
129 } else {
130 el.removeAttr('disabled');
131 el.closest('.well').find('.error').text(data.data.message).show();
132 }
133 }
134 });
135 }
136
137 function renderQrCode() {
138 $('#defender-qr-code').empty().qrcode({
139 text: '<?php echo esc_js( WP_Defender\Component\Two_Factor\Providers\Totp::generate_qr_code( $secret_key ) ); ?>',
140 render: 'div',
141 minVersion: 3,
142 ecLevel: 'L',
143 size: 180
144 });
145 }
146
147 renderQrCode();
148
149 $('body').on('click', '#verify-otp', function () {
150 verifyOtp($(this));
151 })
152
153 $(window).on('keydown', function (event) {
154 if (event.keyCode == 13) {
155 if (jQuery(event.target).attr('id') === 'otp-code') {
156 verifyOtp(jQuery(event.target))
157 }
158 }
159 });
160 })
161 </script>
162