Changeset 2579465
- Timestamp:
- 08/06/2021 05:24:08 PM (5 years ago)
- Location:
- secured-wp
- Files:
-
- 11 edited
- 7 copied
-
tags/1.5 (copied) (copied from secured-wp/trunk)
-
tags/1.5/classes/Controllers/User.php (copied) (copied from secured-wp/trunk/classes/Controllers/User.php) (2 diffs)
-
tags/1.5/classes/Helpers/AjaxRequests.php (modified) (7 diffs)
-
tags/1.5/classes/Helpers/NotifyAdmin.php (modified) (1 diff)
-
tags/1.5/classes/Helpers/OutOfBondEmail.php (modified) (1 diff)
-
tags/1.5/classes/Secured.php (modified) (4 diffs)
-
tags/1.5/classes/Views/LoginForms.php (copied) (copied from secured-wp/trunk/classes/Views/LoginForms.php)
-
tags/1.5/classes/Views/UserProfile.php (modified) (5 diffs)
-
tags/1.5/classes/Views/UsersList.php (copied) (copied from secured-wp/trunk/classes/Views/UsersList.php)
-
tags/1.5/constants.php (copied) (copied from secured-wp/trunk/constants.php)
-
tags/1.5/readme.txt (copied) (copied from secured-wp/trunk/readme.txt)
-
tags/1.5/secured-wp.php (copied) (copied from secured-wp/trunk/secured-wp.php)
-
trunk/classes/Controllers/User.php (modified) (2 diffs)
-
trunk/classes/Helpers/AjaxRequests.php (modified) (7 diffs)
-
trunk/classes/Helpers/NotifyAdmin.php (modified) (1 diff)
-
trunk/classes/Helpers/OutOfBondEmail.php (modified) (1 diff)
-
trunk/classes/Secured.php (modified) (4 diffs)
-
trunk/classes/Views/UserProfile.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
secured-wp/tags/1.5/classes/Controllers/User.php
r2578505 r2579465 300 300 301 301 /** 302 * Unlocks the user 302 * Unlocks the user and clears the login attempts 303 303 * 304 304 * @since 1.0.0 … … 314 314 self::getLockedTransientPrefix() . self::$user->ID 315 315 ); 316 317 LoginAttempts::clearLoginAttempts( $user ); 316 318 } 317 319 -
secured-wp/tags/1.5/classes/Helpers/AjaxRequests.php
r2576070 r2579465 13 13 14 14 use WPSEC\Controllers\User; 15 use WPSEC\Validators\Validator; 15 16 16 17 defined( 'ABSPATH' ) || exit; // Exit if accessed directly. … … 35 36 \add_action( 'wp_ajax_logged_device_delete', [ __CLASS__, 'deleteRememberMeDevice' ] ); 36 37 37 // delete all logged in device for user.38 \add_action( 'wp_ajax_nopriv_all_logged_device_delete', [ __CLASS__, 'deleteAllRememberMeDevice ' ] );39 \add_action( 'wp_ajax_all_logged_device_delete', [ __CLASS__, 'deleteAllRememberMeDevice ' ] );38 // delete all logged in devices for user. 39 \add_action( 'wp_ajax_nopriv_all_logged_device_delete', [ __CLASS__, 'deleteAllRememberMeDevices' ] ); 40 \add_action( 'wp_ajax_all_logged_device_delete', [ __CLASS__, 'deleteAllRememberMeDevices' ] ); 40 41 42 // delete all logged in devices for user. 43 \add_action( 'wp_ajax_nopriv_wps_delete_qr', [ __CLASS__, 'deleteQRCodeForUser' ] ); 44 \add_action( 'wp_ajax_wps_delete_qr', [ __CLASS__, 'deleteQRCodeForUser' ] ); 41 45 } 42 46 … … 63 67 } 64 68 65 if ( empty( $device ) ) {66 $device = base64_decode( $_POST['device']);69 if ( empty( $device ) && isset( $_POST['device'] ) && ! empty( $_POST['device'] ) ) { 70 $device = base64_decode( \sanitize_text_field( \wp_unslash( $_POST['device'] ) ) ); 67 71 } 68 if ( User::deleteLoggedInDevice( $device, $user ) ) { 69 echo \json_encode( [ 'result' => 'success' ] ); 70 } else { 71 echo \json_encode( [ 'result' => 'failed' ] ); 72 73 if ( ! isset( $_POST['user'] ) || empty( $_POST['user'] ) ) { 74 die(); 75 } 76 if ( Validator::filterValidate( \sanitize_text_field( \wp_unslash( $_POST['user'] ) ), 'int' ) ) { 77 78 if ( User::deleteLoggedInDevice( $device, \sanitize_text_field( \wp_unslash( $_POST['user'] ) ) ) ) { 79 echo \json_encode( [ 'result' => 'success' ] ); 80 } else { 81 echo \json_encode( [ 'result' => 'failed' ] ); 82 } 72 83 } 73 84 … … 82 93 * 83 94 * ! WP do_action sends first empty parameter if there are no parameters 84 * @param [type] $user - WP user for which remember me device must be deleted. 95 * TODO: extend this and the method above so it can recieves parameters as well 96 * @param mixed $user - WP user for which remember me device must be deleted. 85 97 * 86 98 * @return void … … 89 101 * @SuppressWarnings(PHPMD.Superglobals) 90 102 */ 91 public static function deleteAllRememberMeDevice ( $user = null ) {103 public static function deleteAllRememberMeDevices( $user = null ) { 92 104 if ( ! isset( $_POST['nonce'] ) || 93 105 empty( $_POST['nonce'] ) || … … 96 108 } 97 109 98 if ( User::deleteAllLoggedInDevices( $user ) ) { 99 echo \json_encode( [ 'result' => 'success' ] ); 100 } else { 101 echo \json_encode( [ 'result' => 'failed' ] ); 110 if ( ! isset( $_POST['user'] ) || empty( $_POST['user'] ) ) { 111 die(); 112 } 113 if ( Validator::filterValidate( \sanitize_text_field( \wp_unslash( $_POST['user'] ) ), 'int' ) ) { 114 if ( User::deleteAllLoggedInDevices( \sanitize_text_field( \wp_unslash( $_POST['user'] ) ) ) ) { 115 echo \json_encode( [ 'result' => 'success' ] ); // @codingStandardsIgnoreLine 116 } else { 117 echo \json_encode( [ 'result' => 'failed' ] ); // @codingStandardsIgnoreLine 118 } 102 119 } 103 120 … … 105 122 } 106 123 124 /** 125 * Deletes QR code for the given user 126 * 127 * @return void 128 * 129 * @since 1.5 130 * 131 * @SuppressWarnings(PHPMD.ExitExpressions) 132 * @SuppressWarnings(PHPMD.Superglobals) 133 */ 134 public static function deleteQRCodeForUser() { 135 if ( ! isset( $_POST['nonce'] ) || 136 empty( $_POST['nonce'] ) || 137 ! \wp_verify_nonce( \sanitize_text_field( \wp_unslash( $_POST['nonce'] ) ), 'wp-secured-wps_delete_qr-ajax-nonce' ) ) { 138 die(); 139 } 140 141 if ( ! isset( $_POST['user'] ) || empty( $_POST['user'] ) ) { 142 die(); 143 } 144 if ( Validator::filterValidate( \sanitize_text_field( \wp_unslash( $_POST['user'] ) ), 'int' ) ) { 145 User::deleteUserTotp( \sanitize_text_field( \wp_unslash( $_POST['user'] ) ) ); 146 echo \json_encode( [ 'result' => 'success' ] ); 147 } 148 149 die(); 150 } 107 151 } 108 152 } -
secured-wp/tags/1.5/classes/Helpers/NotifyAdmin.php
r2577925 r2579465 40 40 41 41 $message = \sprintf( 42 /* 43 translators: %1$s: Name of the user */ 44 /* 45 translators: %2$s: Url of the site */ 46 /* translators: %3$s: Number of the login attempts */ 42 /* translators: %1$s: Name of the user, %2$s: Url of the site, %3$s: Number of the login attempts */ 47 43 __( 'User %1$s has tried to log in with an unsuitable password too many times to your site %2$s.\nThe system has identified %3$s unsuccessful login attempts.', 'ws-secured' ), 48 44 $user->display_name, -
secured-wp/tags/1.5/classes/Helpers/OutOfBondEmail.php
r2576070 r2579465 108 108 109 109 $message = \sprintf( 110 /* 111 translators: %1$s: Name of the user */ 112 /* 113 translators: %2$s: Url of the site */ 114 /* translators: %3$s: Number of the login attempts */ 110 /* translators: %1$s: Name of the user, %2$s: Url of the site, %3$s: Number of the login attempts */ 115 111 __( 'Hello %1$s,<br>Use the following link to login to site %2$s.<br>If not you who is trying to login, please contact the administrator immediately.<br>Click on the following link to login: %3$s', 'ws-secured' ), 116 112 User::getUser( $userId )->display_name, -
secured-wp/tags/1.5/classes/Secured.php
r2577925 r2579465 89 89 <?php 90 90 echo \sprintf( 91 /* translators: %1$s: PHP version */91 /* translators: %1$s: PHP version */ 92 92 \esc_html__( 'You need to update your PHP version to %1s.', 'secured-wp' ), 93 93 WPSEC_REQUIRED_PHP_VERSION // @codingStandardsIgnoreLine - that is defined constatnt no need to escape it … … 110 110 <?php 111 111 echo \sprintf( 112 /* translators: %1$s: WP version */112 /* translators: %1$s: WP version */ 113 113 \esc_html__( 'You need to update your WP version to %1s.', 'secured-wp' ), 114 WPSEC_REQUIRED_WP_VERSION // @codingStandardsIgnoreLine - that is defined constatnt no need to escape it114 WPSEC_REQUIRED_WP_VERSION // @codingStandardsIgnoreLine - that is defined constatnt no need to escape it 115 115 ); 116 116 ?> … … 151 151 'renderPluginSettingsPage', 152 152 ], 153 'data:image/svg+xml;base64,' . \base64_encode( \file_get_contents( WPSEC_PLUGIN_SECURED_PATH . 'assets/images/the-logo.svg' ) ), // @codingStandardsIgnoreLine - :) well that one is necessary153 'data:image/svg+xml;base64,' . \base64_encode( \file_get_contents( WPSEC_PLUGIN_SECURED_PATH . 'assets/images/the-logo.svg' ) ), // @codingStandardsIgnoreLine - :) well that one is necessary 154 154 81 155 155 ); … … 305 305 } 306 306 } 307 308 /** 309 * If user is logged in and there is woocommerce installed and the method is enabled, 310 * we gona need the AJAX methods available. 311 */ 312 if ( User::isCurrentlyLogged() ) { 313 if ( class_exists( 'WooCommerce' ) ) { 314 if ( ! (bool) \WPSEC\Controllers\Modules\TwoFASettings::getGlobalSettingsValue() ) { 315 // AJAX request for the user - do we need this globally for the Admin Part of the WP ?. 316 AjaxRequests::initAdmin(); 317 } 318 } 319 } 307 320 } 308 321 -
secured-wp/tags/1.5/classes/Views/UserProfile.php
r2577925 r2579465 189 189 <?php 190 190 191 \submit_button( 192 __( 'Regenerate QR code', 'secured-wp' ), 193 'delete', 194 'regenerate-qr-code', 195 false 196 ); 191 if ( function_exists( 'submit_button' ) ) { 192 \submit_button( 193 \__( 'Regenerate QR code', 'secured-wp' ), 194 'delete', 195 'regenerate-qr-code', 196 false 197 ); 198 } else { 199 ?> 200 <input type="submit" name="regenerate-qr-code" id="regenerate-qr-code" class="button delete" value="Regenerate QR code"> 201 <?php 202 self::deleteQRCodeJS(); 203 } 197 204 ?> 198 205 </div> … … 214 221 if ( \current_user_can( 'edit_user', $userId ) ) { 215 222 if ( isset( $_POST['qr-nonce'] ) && 216 \wp_verify_nonce( \sanitize_text_field( \wp_unslash( $_POST['qr-nonce'] ) ), self::$qrNoncePrefix . $userId ) &&217 isset( $_POST['regenerate-qr-code'] ) ) {218 219 User::deleteUserTotp( $userId );223 \wp_verify_nonce( \sanitize_text_field( \wp_unslash( $_POST['qr-nonce'] ) ), self::$qrNoncePrefix . $userId ) && 224 isset( $_POST['regenerate-qr-code'] ) ) { 225 226 User::deleteUserTotp( $userId ); 220 227 } 221 228 } … … 238 245 'action': 'logged_device_delete', 239 246 'nonce': '<?php echo \esc_attr( \wp_create_nonce( 'wp-secured-delete_device-ajax-nonce' ) ); ?>', 247 'user': '<?php echo \esc_attr( User::getUser()->ID ); ?>', 240 248 'device': jQuery(this).data('device') // We pass php values differently! 241 249 }; … … 275 283 var deleteData = { 276 284 'action': 'all_logged_device_delete', 285 'user': '<?php echo \esc_attr( User::getUser()->ID ); ?>', 277 286 'nonce': '<?php echo \esc_attr( \wp_create_nonce( 'wp-secured-delete_all_device-ajax-nonce' ) ); ?>', 278 287 }; … … 296 305 <?php 297 306 } 307 308 /** 309 * Javascript for qr code deletion 310 * 311 * @since 1.0.0 312 * 313 * @return void 314 */ 315 private static function deleteQRCodeJS() { 316 ?> 317 <script> 318 ( function( jQuery ) { 319 jQuery('.alignleft').on('click', '#regenerate-qr-code', function(e) { 320 e.preventDefault(); 321 var ajaxurl = "<?php echo \esc_url( admin_url( 'admin-ajax.php' ) ); ?>" 322 var deleteData = { 323 'action': 'wps_delete_qr', 324 'user': '<?php echo \esc_attr( User::getUser()->ID ); ?>', 325 'nonce': '<?php echo \esc_attr( \wp_create_nonce( 'wp-secured-wps_delete_qr-ajax-nonce' ) ); ?>', 326 }; 327 328 let that = this; 329 330 jQuery.ajax({ 331 type: "post", 332 dataType: "json", 333 url: ajaxurl, 334 data: deleteData, 335 success: function( msg ) { 336 if ( 'success' == msg['result'] ) { 337 location.reload(); ; 338 } 339 } 340 }); 341 }); 342 }( jQuery ) ); 343 </script> 344 <?php 345 } 298 346 } 299 347 } -
secured-wp/trunk/classes/Controllers/User.php
r2578505 r2579465 300 300 301 301 /** 302 * Unlocks the user 302 * Unlocks the user and clears the login attempts 303 303 * 304 304 * @since 1.0.0 … … 314 314 self::getLockedTransientPrefix() . self::$user->ID 315 315 ); 316 317 LoginAttempts::clearLoginAttempts( $user ); 316 318 } 317 319 -
secured-wp/trunk/classes/Helpers/AjaxRequests.php
r2576070 r2579465 13 13 14 14 use WPSEC\Controllers\User; 15 use WPSEC\Validators\Validator; 15 16 16 17 defined( 'ABSPATH' ) || exit; // Exit if accessed directly. … … 35 36 \add_action( 'wp_ajax_logged_device_delete', [ __CLASS__, 'deleteRememberMeDevice' ] ); 36 37 37 // delete all logged in device for user.38 \add_action( 'wp_ajax_nopriv_all_logged_device_delete', [ __CLASS__, 'deleteAllRememberMeDevice ' ] );39 \add_action( 'wp_ajax_all_logged_device_delete', [ __CLASS__, 'deleteAllRememberMeDevice ' ] );38 // delete all logged in devices for user. 39 \add_action( 'wp_ajax_nopriv_all_logged_device_delete', [ __CLASS__, 'deleteAllRememberMeDevices' ] ); 40 \add_action( 'wp_ajax_all_logged_device_delete', [ __CLASS__, 'deleteAllRememberMeDevices' ] ); 40 41 42 // delete all logged in devices for user. 43 \add_action( 'wp_ajax_nopriv_wps_delete_qr', [ __CLASS__, 'deleteQRCodeForUser' ] ); 44 \add_action( 'wp_ajax_wps_delete_qr', [ __CLASS__, 'deleteQRCodeForUser' ] ); 41 45 } 42 46 … … 63 67 } 64 68 65 if ( empty( $device ) ) {66 $device = base64_decode( $_POST['device']);69 if ( empty( $device ) && isset( $_POST['device'] ) && ! empty( $_POST['device'] ) ) { 70 $device = base64_decode( \sanitize_text_field( \wp_unslash( $_POST['device'] ) ) ); 67 71 } 68 if ( User::deleteLoggedInDevice( $device, $user ) ) { 69 echo \json_encode( [ 'result' => 'success' ] ); 70 } else { 71 echo \json_encode( [ 'result' => 'failed' ] ); 72 73 if ( ! isset( $_POST['user'] ) || empty( $_POST['user'] ) ) { 74 die(); 75 } 76 if ( Validator::filterValidate( \sanitize_text_field( \wp_unslash( $_POST['user'] ) ), 'int' ) ) { 77 78 if ( User::deleteLoggedInDevice( $device, \sanitize_text_field( \wp_unslash( $_POST['user'] ) ) ) ) { 79 echo \json_encode( [ 'result' => 'success' ] ); 80 } else { 81 echo \json_encode( [ 'result' => 'failed' ] ); 82 } 72 83 } 73 84 … … 82 93 * 83 94 * ! WP do_action sends first empty parameter if there are no parameters 84 * @param [type] $user - WP user for which remember me device must be deleted. 95 * TODO: extend this and the method above so it can recieves parameters as well 96 * @param mixed $user - WP user for which remember me device must be deleted. 85 97 * 86 98 * @return void … … 89 101 * @SuppressWarnings(PHPMD.Superglobals) 90 102 */ 91 public static function deleteAllRememberMeDevice ( $user = null ) {103 public static function deleteAllRememberMeDevices( $user = null ) { 92 104 if ( ! isset( $_POST['nonce'] ) || 93 105 empty( $_POST['nonce'] ) || … … 96 108 } 97 109 98 if ( User::deleteAllLoggedInDevices( $user ) ) { 99 echo \json_encode( [ 'result' => 'success' ] ); 100 } else { 101 echo \json_encode( [ 'result' => 'failed' ] ); 110 if ( ! isset( $_POST['user'] ) || empty( $_POST['user'] ) ) { 111 die(); 112 } 113 if ( Validator::filterValidate( \sanitize_text_field( \wp_unslash( $_POST['user'] ) ), 'int' ) ) { 114 if ( User::deleteAllLoggedInDevices( \sanitize_text_field( \wp_unslash( $_POST['user'] ) ) ) ) { 115 echo \json_encode( [ 'result' => 'success' ] ); // @codingStandardsIgnoreLine 116 } else { 117 echo \json_encode( [ 'result' => 'failed' ] ); // @codingStandardsIgnoreLine 118 } 102 119 } 103 120 … … 105 122 } 106 123 124 /** 125 * Deletes QR code for the given user 126 * 127 * @return void 128 * 129 * @since 1.5 130 * 131 * @SuppressWarnings(PHPMD.ExitExpressions) 132 * @SuppressWarnings(PHPMD.Superglobals) 133 */ 134 public static function deleteQRCodeForUser() { 135 if ( ! isset( $_POST['nonce'] ) || 136 empty( $_POST['nonce'] ) || 137 ! \wp_verify_nonce( \sanitize_text_field( \wp_unslash( $_POST['nonce'] ) ), 'wp-secured-wps_delete_qr-ajax-nonce' ) ) { 138 die(); 139 } 140 141 if ( ! isset( $_POST['user'] ) || empty( $_POST['user'] ) ) { 142 die(); 143 } 144 if ( Validator::filterValidate( \sanitize_text_field( \wp_unslash( $_POST['user'] ) ), 'int' ) ) { 145 User::deleteUserTotp( \sanitize_text_field( \wp_unslash( $_POST['user'] ) ) ); 146 echo \json_encode( [ 'result' => 'success' ] ); 147 } 148 149 die(); 150 } 107 151 } 108 152 } -
secured-wp/trunk/classes/Helpers/NotifyAdmin.php
r2577925 r2579465 40 40 41 41 $message = \sprintf( 42 /* 43 translators: %1$s: Name of the user */ 44 /* 45 translators: %2$s: Url of the site */ 46 /* translators: %3$s: Number of the login attempts */ 42 /* translators: %1$s: Name of the user, %2$s: Url of the site, %3$s: Number of the login attempts */ 47 43 __( 'User %1$s has tried to log in with an unsuitable password too many times to your site %2$s.\nThe system has identified %3$s unsuccessful login attempts.', 'ws-secured' ), 48 44 $user->display_name, -
secured-wp/trunk/classes/Helpers/OutOfBondEmail.php
r2576070 r2579465 108 108 109 109 $message = \sprintf( 110 /* 111 translators: %1$s: Name of the user */ 112 /* 113 translators: %2$s: Url of the site */ 114 /* translators: %3$s: Number of the login attempts */ 110 /* translators: %1$s: Name of the user, %2$s: Url of the site, %3$s: Number of the login attempts */ 115 111 __( 'Hello %1$s,<br>Use the following link to login to site %2$s.<br>If not you who is trying to login, please contact the administrator immediately.<br>Click on the following link to login: %3$s', 'ws-secured' ), 116 112 User::getUser( $userId )->display_name, -
secured-wp/trunk/classes/Secured.php
r2577925 r2579465 89 89 <?php 90 90 echo \sprintf( 91 /* translators: %1$s: PHP version */91 /* translators: %1$s: PHP version */ 92 92 \esc_html__( 'You need to update your PHP version to %1s.', 'secured-wp' ), 93 93 WPSEC_REQUIRED_PHP_VERSION // @codingStandardsIgnoreLine - that is defined constatnt no need to escape it … … 110 110 <?php 111 111 echo \sprintf( 112 /* translators: %1$s: WP version */112 /* translators: %1$s: WP version */ 113 113 \esc_html__( 'You need to update your WP version to %1s.', 'secured-wp' ), 114 WPSEC_REQUIRED_WP_VERSION // @codingStandardsIgnoreLine - that is defined constatnt no need to escape it114 WPSEC_REQUIRED_WP_VERSION // @codingStandardsIgnoreLine - that is defined constatnt no need to escape it 115 115 ); 116 116 ?> … … 151 151 'renderPluginSettingsPage', 152 152 ], 153 'data:image/svg+xml;base64,' . \base64_encode( \file_get_contents( WPSEC_PLUGIN_SECURED_PATH . 'assets/images/the-logo.svg' ) ), // @codingStandardsIgnoreLine - :) well that one is necessary153 'data:image/svg+xml;base64,' . \base64_encode( \file_get_contents( WPSEC_PLUGIN_SECURED_PATH . 'assets/images/the-logo.svg' ) ), // @codingStandardsIgnoreLine - :) well that one is necessary 154 154 81 155 155 ); … … 305 305 } 306 306 } 307 308 /** 309 * If user is logged in and there is woocommerce installed and the method is enabled, 310 * we gona need the AJAX methods available. 311 */ 312 if ( User::isCurrentlyLogged() ) { 313 if ( class_exists( 'WooCommerce' ) ) { 314 if ( ! (bool) \WPSEC\Controllers\Modules\TwoFASettings::getGlobalSettingsValue() ) { 315 // AJAX request for the user - do we need this globally for the Admin Part of the WP ?. 316 AjaxRequests::initAdmin(); 317 } 318 } 319 } 307 320 } 308 321 -
secured-wp/trunk/classes/Views/UserProfile.php
r2577925 r2579465 189 189 <?php 190 190 191 \submit_button( 192 __( 'Regenerate QR code', 'secured-wp' ), 193 'delete', 194 'regenerate-qr-code', 195 false 196 ); 191 if ( function_exists( 'submit_button' ) ) { 192 \submit_button( 193 \__( 'Regenerate QR code', 'secured-wp' ), 194 'delete', 195 'regenerate-qr-code', 196 false 197 ); 198 } else { 199 ?> 200 <input type="submit" name="regenerate-qr-code" id="regenerate-qr-code" class="button delete" value="Regenerate QR code"> 201 <?php 202 self::deleteQRCodeJS(); 203 } 197 204 ?> 198 205 </div> … … 214 221 if ( \current_user_can( 'edit_user', $userId ) ) { 215 222 if ( isset( $_POST['qr-nonce'] ) && 216 \wp_verify_nonce( \sanitize_text_field( \wp_unslash( $_POST['qr-nonce'] ) ), self::$qrNoncePrefix . $userId ) &&217 isset( $_POST['regenerate-qr-code'] ) ) {218 219 User::deleteUserTotp( $userId );223 \wp_verify_nonce( \sanitize_text_field( \wp_unslash( $_POST['qr-nonce'] ) ), self::$qrNoncePrefix . $userId ) && 224 isset( $_POST['regenerate-qr-code'] ) ) { 225 226 User::deleteUserTotp( $userId ); 220 227 } 221 228 } … … 238 245 'action': 'logged_device_delete', 239 246 'nonce': '<?php echo \esc_attr( \wp_create_nonce( 'wp-secured-delete_device-ajax-nonce' ) ); ?>', 247 'user': '<?php echo \esc_attr( User::getUser()->ID ); ?>', 240 248 'device': jQuery(this).data('device') // We pass php values differently! 241 249 }; … … 275 283 var deleteData = { 276 284 'action': 'all_logged_device_delete', 285 'user': '<?php echo \esc_attr( User::getUser()->ID ); ?>', 277 286 'nonce': '<?php echo \esc_attr( \wp_create_nonce( 'wp-secured-delete_all_device-ajax-nonce' ) ); ?>', 278 287 }; … … 296 305 <?php 297 306 } 307 308 /** 309 * Javascript for qr code deletion 310 * 311 * @since 1.0.0 312 * 313 * @return void 314 */ 315 private static function deleteQRCodeJS() { 316 ?> 317 <script> 318 ( function( jQuery ) { 319 jQuery('.alignleft').on('click', '#regenerate-qr-code', function(e) { 320 e.preventDefault(); 321 var ajaxurl = "<?php echo \esc_url( admin_url( 'admin-ajax.php' ) ); ?>" 322 var deleteData = { 323 'action': 'wps_delete_qr', 324 'user': '<?php echo \esc_attr( User::getUser()->ID ); ?>', 325 'nonce': '<?php echo \esc_attr( \wp_create_nonce( 'wp-secured-wps_delete_qr-ajax-nonce' ) ); ?>', 326 }; 327 328 let that = this; 329 330 jQuery.ajax({ 331 type: "post", 332 dataType: "json", 333 url: ajaxurl, 334 data: deleteData, 335 success: function( msg ) { 336 if ( 'success' == msg['result'] ) { 337 location.reload(); ; 338 } 339 } 340 }); 341 }); 342 }( jQuery ) ); 343 </script> 344 <?php 345 } 298 346 } 299 347 }
Note: See TracChangeset
for help on using the changeset viewer.