@@ -43,6 +43,15 @@ function __construct() {
4343 * Used to delete the remote user account.
4444 */
4545 public function cron_system_delete_account () {
46+
47+ if ( ! isset ( $ _GET ['nonce ' ] ) || empty ( $ _GET ['nonce ' ] ) || ! wp_verify_nonce ( $ _GET ['nonce ' ], 'rop_debug ' ) ) {
48+ wp_send_json_error ( array ( 'message ' => __ ( 'Nonce is invalid ' , 'tweet-old-post ' ) ) );
49+ }
50+
51+ if ( ! current_user_can ( 'manage_options ' ) ) {
52+ wp_send_json_error ( array ( 'message ' => __ ( 'Insufficient permissions ' , 'tweet-old-post ' ) ) );
53+ }
54+
4655 $ response = array ();
4756
4857 $ token = get_option ( 'rop_access_token ' , '' );
@@ -83,6 +92,15 @@ public function cron_system_delete_account() {
8392 * @since 0.0.1
8493 */
8594 public function reset_local_client () {
95+
96+ if ( ! isset ( $ _GET ['nonce ' ] ) || empty ( $ _GET ['nonce ' ] ) || ! wp_verify_nonce ( $ _GET ['nonce ' ], 'rop_debug ' ) ) {
97+ wp_send_json_error ( array ( 'message ' => __ ( 'Nonce is invalid ' , 'tweet-old-post ' ) ) );
98+ }
99+
100+ if ( ! current_user_can ( 'manage_options ' ) ) {
101+ wp_send_json_error ( array ( 'message ' => __ ( 'Insufficient permissions ' , 'tweet-old-post ' ) ) );
102+ }
103+
86104 $ response = array ();
87105
88106 // Delete local key.
@@ -110,16 +128,10 @@ public function load_custom_wp_admin_style( $hook ) {
110128 // Load the JS library ony on this page
111129 if ( 'revive-old-posts_page_rop_service_debug ' === $ hook ) {
112130 wp_enqueue_script ( 'rop-debug ' , ROP_LITE_URL . 'cron-system/assets/js/debug-test.js ' , array ( 'jquery ' ), '1.0.0 ' , true );
113- // Generate a pseudo-random string of bytes.
114- $ random_key = Rop_Helpers::openssl_random_pseudo_bytes ();
115- // Auth token creation.
116- $ created_token = hash ( 'sha256 ' , SECURE_AUTH_SALT . $ random_key , false );
117-
118- update_option ( 'rop_temp_debug ' , $ created_token , 'no ' );
119131
120132 $ data_tables = array (
121133 'local_url ' => get_site_url () . '/wp-json/tweet-old-post-cron/v1/debug-test/ ' ,
122- 'nonce ' => $ created_token ,
134+ 'nonce ' => wp_create_nonce ( ' rop_debug ' ) ,
123135 'remote_url ' => ROP_CRON_DOMAIN . '/wp-json/account-status/v1/debug-test/ ' ,
124136 'action_success ' => __ ( 'Request completed ' , 'tweet-old-post ' ),
125137 'action_fail ' => __ ( 'Requested failed to complete. ' , 'tweet-old-post ' ),
0 commit comments