Skip to content

Commit

Permalink
Fixed auth URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Ellis committed Dec 19, 2011
1 parent dfca162 commit edfe352
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 35 deletions.
61 changes: 30 additions & 31 deletions lib/social/controller/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,41 @@ final class Social_Controller_Auth extends Social_Controller {
* @return void
*/
public function action_authorize() {
$proxy = urldecode($this->request->query('target'));
if (strpos($proxy, Social::$api_url) !== false) {
$id = wp_create_nonce('social_authentication');
$url = site_url('index.php');
$args = array(
'social_controller' => 'auth',
'social_action' => 'authorized',
);

if (is_admin()) {
$args['is_admin'] = 'true';
$args['user_id'] = get_current_user_id();
if (defined('IS_PROFILE_PAGE')) {
$args['personal'] = 'true';
$url = add_query_arg('personal', 'true', $url);
}
}
else {
$post_id = $this->request->query('post_id');
if ($post_id !== null) {
$args['p'] = $post_id;
}
$service = urldecode($this->request->query('service'));

// Set the nonce cookie
setcookie('social_auth_nonce', $id, 0, '/');
}
$id = wp_create_nonce('social_authentication');
$url = site_url('index.php');
$args = array(
'social_controller' => 'auth',
'social_action' => 'authorized',
);

$proxy = add_query_arg(array(
'v' => '2',
'id' => $id,
'response_url' => urlencode(add_query_arg($args, $url))
), $proxy);
if (is_admin()) {
$args['is_admin'] = 'true';
$args['user_id'] = get_current_user_id();
if (defined('IS_PROFILE_PAGE')) {
$args['personal'] = 'true';
$url = add_query_arg('personal', 'true', $url);
}
}
else {
$post_id = $this->request->query('post_id');
if ($post_id !== null) {
$args['p'] = $post_id;
}

$proxy = apply_filters('social_proxy_url', $proxy);
// Set the nonce cookie
setcookie('social_auth_nonce', $id, 0, '/');
}

$proxy = add_query_arg(array(
'v' => '2',
'id' => $id,
'response_url' => urlencode(add_query_arg($args, $url))
), Social::$api_url.$service.'/authorize');

$proxy = apply_filters('social_proxy_url', $proxy);

Social::log('Authorizing with URL: '.$proxy);
wp_redirect($proxy);
exit;
Expand Down
5 changes: 1 addition & 4 deletions lib/social/service.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ public function max_broadcast_length() {
public function authorize_url() {
global $post;

$proxy = Social::$api_url.$this->_key.'/authorize';
$url = apply_filters('social_authorize_url', $proxy, $this->_key);

$params = '?social_controller=auth&social_action=authorize&target='.urlencode($url);
$params = '?social_controller=auth&social_action=authorize&service='.urlencode($this->_key);
if (is_admin()) {
$url = (defined('IS_PROFILE_PAGE') ? 'profile.php' : 'index.php');
$url = admin_url($url.$params);
Expand Down

0 comments on commit edfe352

Please sign in to comment.