Changeset 2825867
- Timestamp:
- 11/29/2022 11:23:07 AM (3 years ago)
- Location:
- contentstudio
- Files:
-
- 2 edited
- 1 copied
-
tags/1.1.9/trunk (copied) (copied from contentstudio/trunk)
-
tags/1.1.9/trunk/contentstudio-plugin.php (modified) (7 diffs)
-
trunk/contentstudio-plugin.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
contentstudio/tags/1.1.9/trunk/contentstudio-plugin.php
r2785963 r2825867 3 3 Plugin Name: ContentStudio 4 4 Description: ContentStudio provides you with powerful blogging & social media tools to keep your audience hooked by streamlining the process for you to discover and share engaging content on multiple blogging & social media networks 5 Version: 1.1. 85 Version: 1.1.9 6 6 Author: ContentStudio 7 7 Author URI: http://contentstudio.io/ … … 40 40 protected $assets = 'https://contentstudio.io/img'; 41 41 42 private $version = "1.1. 8";42 private $version = "1.1.9"; 43 43 44 44 protected $contentstudio_id = ''; … … 118 118 add_action('init', [$this, 'cstu_verfiy_wp_user']); 119 119 add_action('init', [$this, 'cstu_check_token']); 120 add_action('init', [$this, 'cstu_set_token']);120 // add_action('init', [$this, 'cstu_set_token']); //remmoved due to security issue 121 121 add_action('init', [$this, 'cstu_get_blog_authors']); 122 122 add_action('init', [$this, 'cstu_get_blog_categories']); … … 463 463 464 464 /** 465 * verify wordpress user 465 * verify wordpress user and set token 466 466 */ 467 467 public function cstu_verfiy_wp_user() … … 469 469 if (isset($_REQUEST['cstu_verfiy_wp_user']) && $_REQUEST['cstu_verfiy_wp_user']) { 470 470 try { 471 if (isset($_REQUEST['username'], $_REQUEST['password'] ) && $_REQUEST['username'] && $_REQUEST['password']) {472 $user = get_user_by('login', $_REQUEST['username']); 471 if (isset($_REQUEST['username'], $_REQUEST['password'], $_REQUEST['token']) && $_REQUEST['username'] && $_REQUEST['password'] && $_REQUEST['token']) { 472 $user = get_user_by('login', $_REQUEST['username']); // validate username 473 473 if ($user && $user->ID != 0) { 474 if (wp_check_password($_REQUEST['password'], $user->data->user_pass, $user->ID)) { 474 if (wp_check_password($_REQUEST['password'], $user->data->user_pass, $user->ID)) { // validate password 475 475 if ($user->has_cap('publish_posts') && $user->has_cap('edit_posts')) { 476 // set token for later requests validation. 477 sanitize_text_field($_REQUEST['token']); 478 update_option('contentstudio_token', $_REQUEST['token']); 479 476 480 echo json_encode(['status' => true, 'message' => 'User verification completed successfully!']); 477 481 die(); … … 499 503 } 500 504 } 501 }502 503 /**504 * check token direct ajax request.505 */506 public function cstu_set_token()507 {508 try {509 if (isset($_REQUEST['cstu_set_token']) && isset($_REQUEST['token'])) {510 /*$valid = get_option('contentstudio_token');511 if (!$valid) {*/512 sanitize_text_field($_REQUEST['token']);513 update_option('contentstudio_token', $_REQUEST['token']);514 515 echo json_encode(['status' => true, 'message' => 'Your token has been updated successfully!']);516 die();517 /*}518 else {519 // TODO: altenrative approach later on...520 echo json_encode(['status' => false, 'message' => 'Token already exists on your website.']);521 die();522 }*/523 }524 }525 catch (Exception $e) {526 echo json_encode(['status' => false, 'message' => self::UNKNOWN_ERROR_MESSAGE,527 'line'=>$e->getLine(), 'error_message' => $e->getMessage()]);528 }529 530 505 } 531 506 … … 1549 1524 return new ContentStudio(); 1550 1525 } 1526 -
contentstudio/trunk/contentstudio-plugin.php
r2785963 r2825867 3 3 Plugin Name: ContentStudio 4 4 Description: ContentStudio provides you with powerful blogging & social media tools to keep your audience hooked by streamlining the process for you to discover and share engaging content on multiple blogging & social media networks 5 Version: 1.1. 85 Version: 1.1.9 6 6 Author: ContentStudio 7 7 Author URI: http://contentstudio.io/ … … 40 40 protected $assets = 'https://contentstudio.io/img'; 41 41 42 private $version = "1.1. 8";42 private $version = "1.1.9"; 43 43 44 44 protected $contentstudio_id = ''; … … 118 118 add_action('init', [$this, 'cstu_verfiy_wp_user']); 119 119 add_action('init', [$this, 'cstu_check_token']); 120 add_action('init', [$this, 'cstu_set_token']);120 // add_action('init', [$this, 'cstu_set_token']); //remmoved due to security issue 121 121 add_action('init', [$this, 'cstu_get_blog_authors']); 122 122 add_action('init', [$this, 'cstu_get_blog_categories']); … … 463 463 464 464 /** 465 * verify wordpress user 465 * verify wordpress user and set token 466 466 */ 467 467 public function cstu_verfiy_wp_user() … … 469 469 if (isset($_REQUEST['cstu_verfiy_wp_user']) && $_REQUEST['cstu_verfiy_wp_user']) { 470 470 try { 471 if (isset($_REQUEST['username'], $_REQUEST['password'] ) && $_REQUEST['username'] && $_REQUEST['password']) {472 $user = get_user_by('login', $_REQUEST['username']); 471 if (isset($_REQUEST['username'], $_REQUEST['password'], $_REQUEST['token']) && $_REQUEST['username'] && $_REQUEST['password'] && $_REQUEST['token']) { 472 $user = get_user_by('login', $_REQUEST['username']); // validate username 473 473 if ($user && $user->ID != 0) { 474 if (wp_check_password($_REQUEST['password'], $user->data->user_pass, $user->ID)) { 474 if (wp_check_password($_REQUEST['password'], $user->data->user_pass, $user->ID)) { // validate password 475 475 if ($user->has_cap('publish_posts') && $user->has_cap('edit_posts')) { 476 // set token for later requests validation. 477 sanitize_text_field($_REQUEST['token']); 478 update_option('contentstudio_token', $_REQUEST['token']); 479 476 480 echo json_encode(['status' => true, 'message' => 'User verification completed successfully!']); 477 481 die(); … … 499 503 } 500 504 } 501 }502 503 /**504 * check token direct ajax request.505 */506 public function cstu_set_token()507 {508 try {509 if (isset($_REQUEST['cstu_set_token']) && isset($_REQUEST['token'])) {510 /*$valid = get_option('contentstudio_token');511 if (!$valid) {*/512 sanitize_text_field($_REQUEST['token']);513 update_option('contentstudio_token', $_REQUEST['token']);514 515 echo json_encode(['status' => true, 'message' => 'Your token has been updated successfully!']);516 die();517 /*}518 else {519 // TODO: altenrative approach later on...520 echo json_encode(['status' => false, 'message' => 'Token already exists on your website.']);521 die();522 }*/523 }524 }525 catch (Exception $e) {526 echo json_encode(['status' => false, 'message' => self::UNKNOWN_ERROR_MESSAGE,527 'line'=>$e->getLine(), 'error_message' => $e->getMessage()]);528 }529 530 505 } 531 506 … … 1549 1524 return new ContentStudio(); 1550 1525 } 1526
Note: See TracChangeset
for help on using the changeset viewer.