Commit 7e5ff770 authored by Ad Schellevis's avatar Ad Schellevis

(auth) add dropKey to api handler

parent e369c686
...@@ -91,6 +91,33 @@ class API implements IAuthConnector ...@@ -91,6 +91,33 @@ class API implements IAuthConnector
return null; return null;
} }
/**
* remove user api key
* @param string $username username
* @param string $apikey api key
* @return bool key found
*/
public function dropKey($username, $apikey)
{
$configObj = Config::getInstance()->object();
foreach ($configObj->system->children() as $key => $value) {
if ($key == 'user' && (string)$username == (string)$value->name) {
if (isset($value->apikeys)) {
$indx=0;
foreach ($value->apikeys->children() as $apiNodeId => $apiNode) {
if ($apiNodeId == 'item' && (string)$apiNode->key == $apikey) {
unset($value->apikeys->item[$indx]);
Config::getInstance()->save();
return true;
}
$indx++;
}
}
}
}
return false;
}
/** /**
* authenticate user against local database (in config.xml) * authenticate user against local database (in config.xml)
* @param string $username username to authenticate * @param string $username username to authenticate
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment