privatekey -> privateKey everywhere
This commit is contained in:
parent
763d394436
commit
3d11286cbc
10 changed files with 41 additions and 41 deletions
|
@ -51,7 +51,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
|
||||||
'primary' => 'uId',
|
'primary' => 'uId',
|
||||||
'username' => 'username',
|
'username' => 'username',
|
||||||
'password' => 'password',
|
'password' => 'password',
|
||||||
'privatekey' => 'privatekey'
|
'privateKey' => 'privateKey'
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $profileurl;
|
protected $profileurl;
|
||||||
|
@ -219,13 +219,13 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
|
||||||
/**
|
/**
|
||||||
* Returns user row from database.
|
* Returns user row from database.
|
||||||
*
|
*
|
||||||
* @param string $privatekey Private Key
|
* @param string $privateKey Private Key
|
||||||
*
|
*
|
||||||
* @return array User array from database, false if no user was found
|
* @return array User array from database, false if no user was found
|
||||||
*/
|
*/
|
||||||
public function getUserByPrivateKey($privatekey)
|
public function getUserByPrivateKey($privateKey)
|
||||||
{
|
{
|
||||||
return $this->_getuser($this->getFieldName('privatekey'), $privatekey);
|
return $this->_getuser($this->getFieldName('privateKey'), $privateKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getObjectUserByUsername($username) {
|
function getObjectUserByUsername($username) {
|
||||||
|
@ -539,24 +539,24 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to authenticate via the privatekey
|
* Try to authenticate via the privateKey
|
||||||
*
|
*
|
||||||
* @param string $privatekey Private Key
|
* @param string $privateKey Private Key
|
||||||
*
|
*
|
||||||
* @return boolean true if the user could be authenticated,
|
* @return boolean true if the user could be authenticated,
|
||||||
* false if not.
|
* false if not.
|
||||||
*/
|
*/
|
||||||
public function loginPrivateKey($privatekey)
|
public function loginPrivateKey($privateKey)
|
||||||
{
|
{
|
||||||
/* Check if private key valid and enabled */
|
/* Check if private key valid and enabled */
|
||||||
if (!$this->isPrivateKeyValid($privatekey)) {
|
if (!$this->isPrivateKeyValid($privateKey)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = 'SELECT '. $this->getFieldName('primary') .' FROM '
|
$query = 'SELECT '. $this->getFieldName('primary') .' FROM '
|
||||||
. $this->getTableName() .' WHERE '
|
. $this->getTableName() .' WHERE '
|
||||||
. $this->getFieldName('privatekey') .' = "'
|
. $this->getFieldName('privateKey') .' = "'
|
||||||
. $this->db->sql_escape($privatekey) .'"';
|
. $this->db->sql_escape($privateKey) .'"';
|
||||||
|
|
||||||
if (!($dbresult = $this->db->sql_query($query))) {
|
if (!($dbresult = $this->db->sql_query($query))) {
|
||||||
message_die(
|
message_die(
|
||||||
|
|
|
@ -99,7 +99,7 @@ class TestBase extends PHPUnit_Framework_TestCase
|
||||||
* @param string $password Password, may be null
|
* @param string $password Password, may be null
|
||||||
* @param mixed $privateKey String private key or boolean true to generate one
|
* @param mixed $privateKey String private key or boolean true to generate one
|
||||||
*
|
*
|
||||||
* @return array ID of user, Name of user, password of user, privatekey
|
* @return array ID of user, Name of user, password of user, privateKey
|
||||||
*/
|
*/
|
||||||
protected function addUserData(
|
protected function addUserData(
|
||||||
$username = null, $password = null, $privateKey = null
|
$username = null, $password = null, $privateKey = null
|
||||||
|
|
|
@ -40,7 +40,7 @@ class UserTest extends TestBase
|
||||||
public function testAddUserPrivateKey()
|
public function testAddUserPrivateKey()
|
||||||
{
|
{
|
||||||
$name = substr(md5(uniqid()), 0, 6);
|
$name = substr(md5(uniqid()), 0, 6);
|
||||||
$pkey = 'my-privatekey';
|
$pkey = 'my-privateKey';
|
||||||
$id = $this->us->addUser(
|
$id = $this->us->addUser(
|
||||||
$name, uniqid(), 'foo@example.org', $pkey
|
$name, uniqid(), 'foo@example.org', $pkey
|
||||||
);
|
);
|
||||||
|
@ -413,17 +413,17 @@ class UserTest extends TestBase
|
||||||
$randKey2 = '-'.$this->us->getNewPrivateKey();
|
$randKey2 = '-'.$this->us->getNewPrivateKey();
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
$this->us->isPrivateKeyValid($randKey2),
|
$this->us->isPrivateKeyValid($randKey2),
|
||||||
'disabled privatekey should return false'
|
'disabled privateKey should return false'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testLoginPrivateKeyInvalid()
|
public function testLoginPrivateKeyInvalid()
|
||||||
{
|
{
|
||||||
/* normal user with enabled privatekey */
|
/* normal user with enabled privateKey */
|
||||||
$randKey = $this->us->getNewPrivateKey();
|
$randKey = $this->us->getNewPrivateKey();
|
||||||
$uid1 = $this->addUser('testusername', 'passw0rd', $randKey);
|
$uid1 = $this->addUser('testusername', 'passw0rd', $randKey);
|
||||||
/* user that has disabled privatekey */
|
/* user that has disabled privateKey */
|
||||||
$randKey2 = '-'.$this->us->getNewPrivateKey();
|
$randKey2 = '-'.$this->us->getNewPrivateKey();
|
||||||
$uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2);
|
$uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2);
|
||||||
|
|
||||||
|
@ -436,10 +436,10 @@ class UserTest extends TestBase
|
||||||
|
|
||||||
public function testLoginPrivateKeyValidEnabledKey()
|
public function testLoginPrivateKeyValidEnabledKey()
|
||||||
{
|
{
|
||||||
/* normal user with enabled privatekey */
|
/* normal user with enabled privateKey */
|
||||||
$randKey = $this->us->getNewPrivateKey();
|
$randKey = $this->us->getNewPrivateKey();
|
||||||
$uid1 = $this->addUser('testusername', 'passw0rd', $randKey);
|
$uid1 = $this->addUser('testusername', 'passw0rd', $randKey);
|
||||||
/* user that has disabled privatekey */
|
/* user that has disabled privateKey */
|
||||||
$randKey2 = '-'.$this->us->getNewPrivateKey();
|
$randKey2 = '-'.$this->us->getNewPrivateKey();
|
||||||
$uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2);
|
$uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2);
|
||||||
|
|
||||||
|
@ -453,10 +453,10 @@ class UserTest extends TestBase
|
||||||
|
|
||||||
public function testLoginPrivateKeyInvalidEnabledKey()
|
public function testLoginPrivateKeyInvalidEnabledKey()
|
||||||
{
|
{
|
||||||
/* normal user with enabled privatekey */
|
/* normal user with enabled privateKey */
|
||||||
$randKey = $this->us->getNewPrivateKey();
|
$randKey = $this->us->getNewPrivateKey();
|
||||||
$uid1 = $this->addUser('testusername', 'passw0rd', $randKey);
|
$uid1 = $this->addUser('testusername', 'passw0rd', $randKey);
|
||||||
/* user that has disabled privatekey */
|
/* user that has disabled privateKey */
|
||||||
$randKey2 = '-'.$this->us->getNewPrivateKey();
|
$randKey2 = '-'.$this->us->getNewPrivateKey();
|
||||||
$uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2);
|
$uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2);
|
||||||
|
|
||||||
|
@ -470,10 +470,10 @@ class UserTest extends TestBase
|
||||||
|
|
||||||
public function testLoginPrivateKeyValidDisabledKey()
|
public function testLoginPrivateKeyValidDisabledKey()
|
||||||
{
|
{
|
||||||
/* normal user with enabled privatekey */
|
/* normal user with enabled privateKey */
|
||||||
$randKey = $this->us->getNewPrivateKey();
|
$randKey = $this->us->getNewPrivateKey();
|
||||||
$uid1 = $this->addUser('testusername', 'passw0rd', $randKey);
|
$uid1 = $this->addUser('testusername', 'passw0rd', $randKey);
|
||||||
/* user that has disabled privatekey */
|
/* user that has disabled privateKey */
|
||||||
$randKey2 = '-'.$this->us->getNewPrivateKey();
|
$randKey2 = '-'.$this->us->getNewPrivateKey();
|
||||||
$uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2);
|
$uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2);
|
||||||
|
|
||||||
|
@ -491,10 +491,10 @@ class UserTest extends TestBase
|
||||||
|
|
||||||
public function testLoginPrivateKeyInvalidDisabled()
|
public function testLoginPrivateKeyInvalidDisabled()
|
||||||
{
|
{
|
||||||
/* normal user with enabled privatekey */
|
/* normal user with enabled privateKey */
|
||||||
$randKey = $this->us->getNewPrivateKey();
|
$randKey = $this->us->getNewPrivateKey();
|
||||||
$uid1 = $this->addUser('testusername', 'passw0rd', $randKey);
|
$uid1 = $this->addUser('testusername', 'passw0rd', $randKey);
|
||||||
/* user that has disabled privatekey */
|
/* user that has disabled privateKey */
|
||||||
$randKey2 = '-'.$this->us->getNewPrivateKey();
|
$randKey2 = '-'.$this->us->getNewPrivateKey();
|
||||||
$uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2);
|
$uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2);
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ class www_bookmarksTest extends TestBaseApi
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
2, count($elements), 'Number of Links in Head not correct'
|
2, count($elements), 'Number of Links in Head not correct'
|
||||||
);
|
);
|
||||||
$this->assertContains('privatekey=', (string)$elements[1]['href']);
|
$this->assertContains('privateKey=', (string)$elements[1]['href']);
|
||||||
}//end testVerifyPrivateRSSLinkExists
|
}//end testVerifyPrivateRSSLinkExists
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ class www_bookmarksTest extends TestBaseApi
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
1, count($elements), 'Number of Links in Head not correct'
|
1, count($elements), 'Number of Links in Head not correct'
|
||||||
);
|
);
|
||||||
$this->assertNotContains('privatekey=', (string)$elements[0]['href']);
|
$this->assertNotContains('privateKey=', (string)$elements[0]['href']);
|
||||||
}//end testVerifyPrivateRSSLinkDoesNotExist
|
}//end testVerifyPrivateRSSLinkDoesNotExist
|
||||||
|
|
||||||
}//end class www_bookmarksTest
|
}//end class www_bookmarksTest
|
||||||
|
|
|
@ -26,7 +26,7 @@ class www_indexTest extends TestBaseApi
|
||||||
|
|
||||||
$elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]');
|
$elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]');
|
||||||
$this->assertEquals(2, count($elements), 'Number of Links in Head not correct');
|
$this->assertEquals(2, count($elements), 'Number of Links in Head not correct');
|
||||||
$this->assertContains('privatekey=', (string)$elements[1]['href']);
|
$this->assertContains('privateKey=', (string)$elements[1]['href']);
|
||||||
}//end testVerifyPrivateRSSLinkExists
|
}//end testVerifyPrivateRSSLinkExists
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class www_indexTest extends TestBaseApi
|
||||||
|
|
||||||
$elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]');
|
$elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]');
|
||||||
$this->assertEquals(1, count($elements), 'Number of Links in Head not correct');
|
$this->assertEquals(1, count($elements), 'Number of Links in Head not correct');
|
||||||
$this->assertNotContains('privatekey=', (string)$elements[0]['href']);
|
$this->assertNotContains('privateKey=', (string)$elements[0]['href']);
|
||||||
}//end testVerifyPrivateRSSLinkDoesNotExist
|
}//end testVerifyPrivateRSSLinkDoesNotExist
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ class www_rssTest extends TestBaseApi
|
||||||
null, 'private bookmark'
|
null, 'private bookmark'
|
||||||
);
|
);
|
||||||
|
|
||||||
$req = $this->getRequest('?privatekey=' . $privateKey);
|
$req = $this->getRequest('?privateKey=' . $privateKey);
|
||||||
$response_body = $req->send()->getBody();
|
$response_body = $req->send()->getBody();
|
||||||
|
|
||||||
$rss = simplexml_load_string($response_body);
|
$rss = simplexml_load_string($response_body);
|
||||||
|
@ -103,7 +103,7 @@ class www_rssTest extends TestBaseApi
|
||||||
null, 'private bookmark'
|
null, 'private bookmark'
|
||||||
);
|
);
|
||||||
|
|
||||||
$req = $this->getRequest('/' . $username . '?privatekey=' . $privateKey);
|
$req = $this->getRequest('/' . $username . '?privateKey=' . $privateKey);
|
||||||
$response_body = $req->send()->getBody();
|
$response_body = $req->send()->getBody();
|
||||||
|
|
||||||
$rss = simplexml_load_string($response_body);
|
$rss = simplexml_load_string($response_body);
|
||||||
|
@ -129,7 +129,7 @@ class www_rssTest extends TestBaseApi
|
||||||
null, 'private bookmark'
|
null, 'private bookmark'
|
||||||
);
|
);
|
||||||
|
|
||||||
$req = $this->getRequest('/' . $username . '?privatekey=' . $privateKey);
|
$req = $this->getRequest('/' . $username . '?privateKey=' . $privateKey);
|
||||||
$cookies = $req->setCookieJar()->getCookieJar();
|
$cookies = $req->setCookieJar()->getCookieJar();
|
||||||
$response_body = $req->send()->getBody();
|
$response_body = $req->send()->getBody();
|
||||||
|
|
||||||
|
|
|
@ -276,7 +276,7 @@ if ($templatename == 'editbookmark.tpl') {
|
||||||
$tplVars['rsschannels'],
|
$tplVars['rsschannels'],
|
||||||
array(
|
array(
|
||||||
filter($sitename . $rssTitle. sprintf(T_(': (private) ')) . $currentUsername),
|
filter($sitename . $rssTitle. sprintf(T_(': (private) ')) . $currentUsername),
|
||||||
createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privatekey='.$currentUser->getPrivateKey())
|
createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privateKey='.$currentUser->getPrivateKey())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ if ($userservice->isLoggedOn()) {
|
||||||
$tplVars['rsschannels'],
|
$tplVars['rsschannels'],
|
||||||
array(
|
array(
|
||||||
filter(sprintf(T_('%s: Recent bookmarks (+private) %s'), $sitename, $currentUsername)),
|
filter(sprintf(T_('%s: Recent bookmarks (+private) %s'), $sitename, $currentUsername)),
|
||||||
createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privatekey='.$currentUser->getPrivateKey())
|
createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privateKey='.$currentUser->getPrivateKey())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
16
www/rss.php
16
www/rss.php
|
@ -64,9 +64,9 @@ if (!isset($rssEntries) || $rssEntries <= 0) {
|
||||||
$rssEntries = $maxRssEntries;
|
$rssEntries = $maxRssEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
$privatekey = null;
|
$privateKey = null;
|
||||||
if (isset($_GET['privatekey'])) {
|
if (isset($_GET['privateKey'])) {
|
||||||
$privatekey = $_GET['privatekey'];
|
$privateKey = $_GET['privateKey'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$userid = null;
|
$userid = null;
|
||||||
|
@ -83,10 +83,10 @@ if ($user && $user != 'all') {
|
||||||
} else {
|
} else {
|
||||||
if ($userinfo = $userservice->getUserByUsername($user)) {
|
if ($userinfo = $userservice->getUserByUsername($user)) {
|
||||||
$userid =& $userinfo[$userservice->getFieldName('primary')];
|
$userid =& $userinfo[$userservice->getFieldName('primary')];
|
||||||
/* if user is not logged in and has valid privatekey */
|
/* if user is not logged in and has valid privateKey */
|
||||||
if (!$userservice->isLoggedOn()) {
|
if (!$userservice->isLoggedOn()) {
|
||||||
if ($privatekey != null) {
|
if ($privateKey != null) {
|
||||||
if (!$userservice->loginPrivateKey($privatekey)) {
|
if (!$userservice->loginPrivateKey($privateKey)) {
|
||||||
$tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user);
|
$tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user);
|
||||||
header('Content-type: text/html; charset=utf-8');
|
header('Content-type: text/html; charset=utf-8');
|
||||||
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
||||||
|
@ -106,8 +106,8 @@ if ($user && $user != 'all') {
|
||||||
}
|
}
|
||||||
$pagetitle .= ": ". $user;
|
$pagetitle .= ": ". $user;
|
||||||
} else {
|
} else {
|
||||||
if ($privatekey != null) {
|
if ($privateKey != null) {
|
||||||
if (!$userservice->loginPrivateKey($privatekey)) {
|
if (!$userservice->loginPrivateKey($privateKey)) {
|
||||||
$tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user);
|
$tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user);
|
||||||
header('Content-type: text/html; charset=utf-8');
|
header('Content-type: text/html; charset=utf-8');
|
||||||
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
||||||
|
|
|
@ -77,7 +77,7 @@ if ($userservice->isLoggedOn()) {
|
||||||
$tplVars['rsschannels'],
|
$tplVars['rsschannels'],
|
||||||
array(
|
array(
|
||||||
filter($sitename .': Tags: '. $cat . sprintf(T_(': (private) ')) . $currentUsername),
|
filter($sitename .': Tags: '. $cat . sprintf(T_(': (private) ')) . $currentUsername),
|
||||||
createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privatekey='.$currentUser->getPrivateKey())
|
createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privateKey='.$currentUser->getPrivateKey())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue