diff options
Diffstat (limited to 'application/controllers')
-rw-r--r-- | application/controllers/api/v1/api_info.php | 2 | ||||
-rw-r--r-- | application/controllers/api/v1/user.php | 27 |
2 files changed, 28 insertions, 1 deletions
diff --git a/application/controllers/api/v1/api_info.php b/application/controllers/api/v1/api_info.php index e5e99f771..e7738294e 100644 --- a/application/controllers/api/v1/api_info.php +++ b/application/controllers/api/v1/api_info.php @@ -11,6 +11,6 @@ namespace controllers\api\v1; class api_info extends \controllers\api\api_controller { static public function get_version() { - return "1.1.0"; + return "1.2.0"; } } diff --git a/application/controllers/api/v1/user.php b/application/controllers/api/v1/user.php index e49b7c657..e96a6c6fb 100644 --- a/application/controllers/api/v1/user.php +++ b/application/controllers/api/v1/user.php @@ -36,4 +36,31 @@ class user extends \controllers\api\api_controller { "new_key" => $key, ); } + + public function delete_apikey() + { + $this->muser->require_access("full"); + + $userid = $this->muser->get_userid(); + $key = $this->input->post("delete_key"); + + $this->db->where('user', $userid) + ->where('key', $key) + ->delete('apikeys'); + + $affected = $this->db->affected_rows(); + + assert($affected >= 0 && $affected <= 1); + if ($affected == 1) { + return array( + "deleted_keys" => array( + $key => array ( + "key" => $key, + ), + ), + ); + } else { + throw new \exceptions\PublicApiException('user/delete_apikey/failed', 'Apikey deletion failed. Possibly wrong owner.'); + } + } } |