First pass at complete global API
This commit is contained in:
@@ -97,8 +97,16 @@ class DomainStatusNetworkPlugin extends Plugin
|
||||
|
||||
switch ($cls)
|
||||
{
|
||||
case 'GlobalregisterAction':
|
||||
case 'GloballoginAction':
|
||||
case 'GlobalrecoverAction':
|
||||
include_once $dir . '/actions/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
|
||||
return false;
|
||||
case 'DomainStatusNetworkInstaller':
|
||||
include_once $dir . '/' . strtolower($cls) . '.php';
|
||||
include_once $dir . '/lib/' . strtolower($cls) . '.php';
|
||||
return false;
|
||||
case 'GlobalApiAction':
|
||||
include_once $dir . '/lib/' . strtolower($cls) . '.php';
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
@@ -138,6 +146,17 @@ class DomainStatusNetworkPlugin extends Plugin
|
||||
return true;
|
||||
}
|
||||
|
||||
function onRouterInitialized($m)
|
||||
{
|
||||
if (common_config('globalapi', 'enabled')) {
|
||||
foreach (array('register', 'login', 'recover') as $method) {
|
||||
$m->connect('api/statusnet/global/'.$method,
|
||||
array('action' => 'global'.$method));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static function nicknameForDomain($domain)
|
||||
{
|
||||
$registered = self::registeredDomain($domain);
|
||||
@@ -261,12 +280,16 @@ class DomainStatusNetworkPlugin extends Plugin
|
||||
$loginToken = Login_token::makeNew($user);
|
||||
|
||||
if (empty($loginToken)) {
|
||||
throw new ServerException(_('Cannot log in.'));
|
||||
throw new ServerException(sprintf(_('Could not create new login token for user %s'), $user->nickname));
|
||||
}
|
||||
|
||||
$url = common_local_url('otp', array('user_id' => $loginToken->user_id,
|
||||
'token' => $loginToken->token));
|
||||
|
||||
if (empty($url)) {
|
||||
throw new ServerException(sprintf(_('Could not create new OTP URL for user %s'), $user->nickname));
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
@@ -282,6 +305,12 @@ class DomainStatusNetworkPlugin extends Plugin
|
||||
|
||||
StatusNet::switchSite($sn->nickname);
|
||||
|
||||
$user = User::staticGet('email', $email);
|
||||
|
||||
if (empty($user)) {
|
||||
throw new ClientException(_('No such user.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The way addPlugin() works, this global variable gets disappeared.
|
||||
|
||||
Reference in New Issue
Block a user