Merge remote branch 'upstream/master'
This commit is contained in:
@@ -1,18 +1,21 @@
|
||||
<?php
|
||||
|
||||
class Application
|
||||
class Services_Rest_Application
|
||||
{
|
||||
protected function get($id = null)
|
||||
protected function get($id = '', $type = null, $start = null, $limit = null)
|
||||
{
|
||||
if (is_null($id)) {
|
||||
if (empty($id)) {
|
||||
// getting all records.
|
||||
G::loadClass('applications');
|
||||
$app->getAll($userUid, $start=null, $limit=null, $action=null);
|
||||
$app = new Applications();
|
||||
$userUid = Services_Rest_Auth::$userId;
|
||||
|
||||
return $app->getAll($userUid, $start, $limit, $type);
|
||||
} else {
|
||||
// get a specific record.
|
||||
G::loadClass('wsBase');
|
||||
$case = new wsBase();
|
||||
$case->getCaseInfo($id);
|
||||
$wsBase = new wsBase();
|
||||
return $wsBase->getCaseInfo($id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
G::LoadClass('sessions');
|
||||
G::LoadClass('wsBase');
|
||||
|
||||
class Auth implements iAuthenticate
|
||||
class Services_Rest_Auth implements iAuthenticate
|
||||
{
|
||||
public $realm = 'Restricted API';
|
||||
|
||||
public static $userId = '';
|
||||
public static $authKey = '';
|
||||
|
||||
function __isAuthenticated()
|
||||
{
|
||||
if (array_key_exists('HTTP_AUTH_KEY', $_SERVER)) {
|
||||
@@ -20,18 +23,13 @@ class Auth implements iAuthenticate
|
||||
$session = $sessions->verifySession($authKey);
|
||||
|
||||
if (is_array($session)) {
|
||||
$sesInfo = $sessions->getSessionUser($authKey);
|
||||
self::$userId = $sesInfo['USR_UID'];
|
||||
self::$authKey = $authKey;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new RestException(401, 'Wrong Credentials!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST
|
||||
*/
|
||||
public function login($user, $passwd)
|
||||
{
|
||||
$wsBase = new wsBase();
|
||||
return $wsBase->login($user, $passwd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,16 @@
|
||||
G::loadClass('wsBase');
|
||||
G::LoadClass('sessions');
|
||||
|
||||
class Login
|
||||
class Services_Rest_Login
|
||||
{
|
||||
public function post($user, $passwd)
|
||||
public function post($user, $password)
|
||||
{
|
||||
$wsBase = new wsBase();
|
||||
$result = $wsBase->login($user, $passwd);
|
||||
$result = $wsBase->login($user, $password);
|
||||
|
||||
if ($result->status_code == 0) {
|
||||
return array(
|
||||
'auth_key' => $result->message,
|
||||
//'timestamp' => $result->timestamp,
|
||||
);
|
||||
} else {
|
||||
throw new RestException(401, $result->message);
|
||||
|
||||
Reference in New Issue
Block a user