Skip to content

Commit 02cc708

Browse files
committed
Improved user-specific nonce validation. Fixes #13
1 parent b6e1d34 commit 02cc708

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

assets/js/admin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
e.preventDefault();
1717
var $this = $(this);
1818
var action = $this.attr('data-dul-action');
19+
var nonce = $this.attr('data-dul-nonce');
1920
var user_id = $this.data('dul-user-id');
2021

2122
var data = {
@@ -24,7 +25,7 @@
2425
user_id: user_id,
2526
action: action
2627
},
27-
nonce: SSDUL.nonces.quick_links
28+
nonce: nonce //SSDUL.nonces.quick_links
2829
};
2930

3031
console.log(`${action} user id: ${user_id}`);

disable-user-login.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Disable User Login
44
* Plugin URI: http://wordpress.org/plugins/disable-user-login
55
* Description: Provides the ability to disable user accounts and prevent them from logging in.
6-
* Version: 1.3.7
6+
* Version: 1.3.8
77
*
88
* Author: Saint Systems
99
* Author URI: https://www.saintsystems.com

includes/class-ss-disable-user-login-plugin.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ final class SS_Disable_User_Login_Plugin {
1515
*
1616
* @var string
1717
*/
18-
private static $version = '1.3.7';
18+
private static $version = '1.3.8';
1919

2020
/**
2121
* Plugin singleton instance
@@ -165,7 +165,8 @@ function add_quick_links( $actions, $user_object ) {
165165
$action = 'enable';
166166
$label = _x( 'Enable', 'user row action', 'disable-user-login' );
167167
}
168-
$actions[ 'disable_user_login' ] = "<a class='dul-quick-links' href='#' data-dul-action='$action' data-dul-user-id='$user_object->ID'>" . $label . '</a>';
168+
$nonce = wp_create_nonce( sprintf( 'ssdul_enable_disable_user_%s', $user_object->ID ) );
169+
$actions[ 'disable_user_login' ] = "<a class='dul-quick-links' href='#' data-dul-action='$action' data-dul-nonce='$nonce' data-dul-user-id='$user_object->ID'>" . $label . '</a>';
169170
}
170171
return $actions;
171172
}
@@ -321,7 +322,7 @@ public function can_disable( $user_id ) {
321322
*/
322323
public function enable_disable_user() {
323324

324-
check_ajax_referer( 'ssdul_quick_links', 'nonce' );
325+
// check_ajax_referer( 'ssdul_quick_links', 'nonce' );
325326

326327
if ( empty( $_POST['data'] ) ) return;
327328

@@ -331,6 +332,8 @@ public function enable_disable_user() {
331332

332333
$action = $data['action'];
333334

335+
check_ajax_referer( sprintf( 'ssdul_enable_disable_user_%s', $user_id ), 'nonce' );
336+
334337
if ( ! $this->can_disable( $user_id ) ) {
335338
$response = array(
336339
'error' => sprintf( 'User %s cannot disable user $s.', get_current_user_id(), $user_id )

readme.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ Contributors: saintsystems, anderly
33
Donate link: https://ssms.us/donate
44
Tags: users, user, login, account, disable
55
Requires at least: 4.7.0
6-
Tested up to: 6.3
6+
Tested up to: 6.4.2
77
Requires PHP: 5.6
8-
Stable tag: 1.3.7
9-
Version: 1.3.7
8+
Stable tag: 1.3.8
9+
Version: 1.3.8
1010
License: GPLv3
1111

1212
Provides the ability to disable user accounts and prevent them from logging in.
@@ -49,6 +49,9 @@ Yes, there is a filter in place for that, `disable_user_login.disabled_message`.
4949

5050
== Changelog ==
5151

52+
= 1.3.8 =
53+
* Improved user-specific nonce validation.
54+
5255
= 1.3.7 =
5356
* Add hooks for multisite.
5457

0 commit comments

Comments
 (0)