interim commit after pull from server
darcs-hash:20080530142324-84dde-782c9f04f551447514f1557b9e80f8461a17771f.gz
This commit is contained in:
parent
9210f95633
commit
c501b7b925
|
@ -24,7 +24,7 @@ class AccesstokenAction extends Action {
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
try {
|
try {
|
||||||
$req = OAuthRequest::from_request();
|
$req = OAuthRequest::from_request();
|
||||||
$server = common_oauth_server();
|
$server = omb_oauth_server();
|
||||||
$token = $server->fetch_access_token($req);
|
$token = $server->fetch_access_token($req);
|
||||||
print $token;
|
print $token;
|
||||||
} catch (OAuthException $e) {
|
} catch (OAuthException $e) {
|
||||||
|
|
|
@ -44,9 +44,16 @@ class LoginAction extends Action {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
# success!
|
# success!
|
||||||
common_redirect(common_local_url('all',
|
$url = common_get_returnto();
|
||||||
|
if ($url) {
|
||||||
|
# We don't have to return to it again
|
||||||
|
common_set_returnto(NULL);
|
||||||
|
} else {
|
||||||
|
$url = common_local_url('all',
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$nickname)));
|
$nickname));
|
||||||
|
}
|
||||||
|
common_redirect($url);
|
||||||
} else {
|
} else {
|
||||||
$this->show_form(_t('Incorrect username or password.'));
|
$this->show_form(_t('Incorrect username or password.'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ class RequesttokenAction extends Action {
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
try {
|
try {
|
||||||
$req = OAuthRequest::from_request();
|
$req = OAuthRequest::from_request();
|
||||||
$server = common_oauth_server();
|
$server = omb_oauth_server();
|
||||||
$token = $server->fetch_request_token($req);
|
$token = $server->fetch_request_token($req);
|
||||||
print $token;
|
print $token;
|
||||||
} catch (OAuthException $e) {
|
} catch (OAuthException $e) {
|
||||||
|
|
|
@ -29,7 +29,10 @@ class UserauthorizationAction extends Action {
|
||||||
try {
|
try {
|
||||||
$req = $this->get_request();
|
$req = $this->get_request();
|
||||||
$server = common_oauth_server();
|
$server = common_oauth_server();
|
||||||
list($consumer, $token) = $server->verify_request($req);
|
$server->get_version($req);
|
||||||
|
$consumer = $server->get_consumer($req);
|
||||||
|
$token = $server->get_token($req, $consumer, "request");
|
||||||
|
$server->check_signature($req, $consumer, $token);
|
||||||
} catch (OAuthException $e) {
|
} catch (OAuthException $e) {
|
||||||
$this->clear_request();
|
$this->clear_request();
|
||||||
common_server_error($e->getMessage());
|
common_server_error($e->getMessage());
|
||||||
|
@ -39,7 +42,8 @@ class UserauthorizationAction extends Action {
|
||||||
if (common_logged_in()) {
|
if (common_logged_in()) {
|
||||||
$this->show_form($req);
|
$this->show_form($req);
|
||||||
} else {
|
} else {
|
||||||
common_return_to(common_local_url('userauthorization'));
|
# Go log in, and then come back
|
||||||
|
common_set_returnto(common_local_url('userauthorization'));
|
||||||
common_redirect(common_local_url('login'));
|
common_redirect(common_local_url('login'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,8 +60,10 @@ class UserauthorizationAction extends Action {
|
||||||
if (!$req) {
|
if (!$req) {
|
||||||
# XXX: may have an uncaught exception
|
# XXX: may have an uncaught exception
|
||||||
$req = OAuthRequest::from_request();
|
$req = OAuthRequest::from_request();
|
||||||
|
if ($req) {
|
||||||
$this->store_request($req);
|
$this->store_request($req);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return $req;
|
return $req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +75,7 @@ class UserauthorizationAction extends Action {
|
||||||
|
|
||||||
function send_authorization() {
|
function send_authorization() {
|
||||||
$req = $this->get_request();
|
$req = $this->get_request();
|
||||||
|
|
||||||
if (!$req) {
|
if (!$req) {
|
||||||
common_user_error(_t('No authorization request!'));
|
common_user_error(_t('No authorization request!'));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -9,5 +9,7 @@ This package requires PHP 5.x and the following PHP Pear libraries:
|
||||||
use the openidenabled.com libraries for OpenID auth sometime in the
|
use the openidenabled.com libraries for OpenID auth sometime in the
|
||||||
future. Note that this is no longer distributed separately; it's only
|
future. Note that this is no longer distributed separately; it's only
|
||||||
in the openidenabled.com OpenID PHP tarball.
|
in the openidenabled.com OpenID PHP tarball.
|
||||||
|
http://openidenabled.com/php-openid/
|
||||||
|
- OAuth.php from http://oauth.googlecode.com/svn/code/php/
|
||||||
|
- markdown.php from http://michelf.com/projects/php-markdown/
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ require_once(INSTALLDIR.'/lib/omb.php');
|
||||||
|
|
||||||
class LaconicaOAuthDataStore extends OAuthDataStore {
|
class LaconicaOAuthDataStore extends OAuthDataStore {
|
||||||
|
|
||||||
# We just keep a record of who's contacted us
|
# We keep a record of who's contacted us
|
||||||
|
|
||||||
function lookup_consumer($consumer_key) {
|
function lookup_consumer($consumer_key) {
|
||||||
$con = new Consumer('key', $consumer_key);
|
$con = new Consumer('key', $consumer_key);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
if (!defined('LACONICA')) { exit(1); }
|
if (!defined('LACONICA')) { exit(1); }
|
||||||
|
|
||||||
require_once('OAuth.php');
|
require_once('OAuth.php');
|
||||||
|
require_once(INSTALLDIR.'lib/oauthstore.php');
|
||||||
|
|
||||||
define('OAUTH_NAMESPACE', 'http://oauth.net/core/1.0/');
|
define('OAUTH_NAMESPACE', 'http://oauth.net/core/1.0/');
|
||||||
define('OMB_NAMESPACE', 'http://openmicroblogging.org/protocol/0.1');
|
define('OMB_NAMESPACE', 'http://openmicroblogging.org/protocol/0.1');
|
||||||
|
@ -44,6 +45,14 @@ function omb_oauth_consumer() {
|
||||||
return $con;
|
return $con;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function omb_oauth_server() {
|
||||||
|
static $server = null;
|
||||||
|
if ($server) {
|
||||||
|
$server = new OAuthServer(new LaconicaOAuthStore());
|
||||||
|
}
|
||||||
|
return $server;
|
||||||
|
}
|
||||||
|
|
||||||
function omb_hmac_sha1() {
|
function omb_hmac_sha1() {
|
||||||
static $hmac_method = NULL;
|
static $hmac_method = NULL;
|
||||||
if (!$hmac_method) {
|
if (!$hmac_method) {
|
||||||
|
|
10
lib/util.php
10
lib/util.php
|
@ -525,6 +525,16 @@ function common_mtrand($bytes) {
|
||||||
return $enc;
|
return $enc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function common_set_returnto($url) {
|
||||||
|
common_ensure_session();
|
||||||
|
$_SESSION['returnto'] = $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
function common_get_returnto() {
|
||||||
|
common_ensure_session();
|
||||||
|
return $_SESSION['returnto'];
|
||||||
|
}
|
||||||
|
|
||||||
function common_timestamp() {
|
function common_timestamp() {
|
||||||
return date('YmdHis');
|
return date('YmdHis');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user