Changeset 595581
- Timestamp:
- 09/06/2012 09:01:34 PM (14 years ago)
- Location:
- kickpress/trunk
- Files:
-
- 2 edited
-
kickpress-oauth.php (modified) (8 diffs)
-
kickpress-redirects.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
kickpress/trunk/kickpress-oauth.php
r595539 r595581 82 82 } 83 83 84 function kickpress_oauth_authenticate() { 85 kickpress_oauth_provider::authenticate(); 86 } 87 84 88 class kickpress_oauth { 85 89 public static function get_args() { … … 248 252 protected $_verifier; 249 253 254 protected $_user_id; 255 protected $_blog_id; 256 250 257 public function __construct( $args = array() ) { 251 258 parent::__construct( $args ); … … 263 270 public function set_verifier( $verifier ) { 264 271 $this->_verifier = $verifier; 272 } 273 274 public function set_user_id( $user_id ) { 275 $this->_user_id = $user_id; 276 } 277 278 public function set_blog_id( $blog_id ) { 279 $this->_blog_id = $blog_id; 265 280 } 266 281 … … 461 476 } 462 477 478 public static function authenticate( $args = null ) { 479 self::$_action = 'authenticate'; 480 481 if ( isset( $_SERVER['HTTP_AUTHORIZATION'] ) ) { 482 $consumer = self::validate_consumer( $args ); 483 484 if ( ! is_wp_error( $consumer ) ) 485 wp_set_current_user( $consumer->user_id ); 486 } 487 } 488 463 489 public static function validate_consumer( $args = null ) { 464 490 if ( ! isset( $_SERVER['HTTP_AUTHORIZATION'] ) ) { … … 473 499 if ( is_null( $args ) ) $args = self::get_args(); 474 500 475 $provider = new self();501 $provider = new self(); 476 502 477 503 if ( $oauth = $provider->parse_signature() ) { … … 483 509 $token_actions = array( 484 510 'access-token', 485 ' resource'511 'authenticate' 486 512 ); 487 513 … … 507 533 } 508 534 } 509 } elseif ( ' oauth-resource' == self::$_action ) {535 } elseif ( 'authenticate' == self::$_action ) { 510 536 $meta = kickpress_user_meta_query( 0, 511 537 'kickpress\_oauth\_access\_token\_%', … … 513 539 514 540 if ( $meta = array_shift( $meta ) ) { 515 $token = $option->oauth_token; 516 $token_secret = $option->oauth_token_secret; 541 $token = $meta->oauth_token; 542 $token_secret = $meta->oauth_secret; 543 544 $consumer->set_user_id( $meta->user_id ); 545 $consumer->set_blog_id( $meta->blog_id ); 517 546 } 518 547 } -
kickpress/trunk/kickpress-redirects.php
r587972 r595581 44 44 $blogurl = ((get_option('home')) ? get_option('home') : get_option('siteurl')); 45 45 preg_match('#^[hpst]+://.*?(/.*)$#', $blogurl, $subdir); 46 47 kickpress_oauth_authenticate(); 46 48 47 49 if ( isset($subdir[1]) ) {
Note: See TracChangeset
for help on using the changeset viewer.