diff options
author | Florian Pritz <bluewind@xinu.at> | 2015-03-25 11:38:33 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2015-03-25 11:41:07 +0100 |
commit | 8dd9fbe3912d74ab37d6654e83af8dd8fdf9d320 (patch) | |
tree | e33be87903bc61b0dee3d49a21aa66d75b77b76d /application/controllers/api/v1/user.php | |
parent | f51f0130cdda5110e17d2ac9953b4143c7b42206 (diff) |
API 1.2.0: Add user/delete_apikeys endpoint
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/controllers/api/v1/user.php')
-rw-r--r-- | application/controllers/api/v1/user.php | 27 |
1 files changed, 27 insertions, 0 deletions
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.'); + } + } } |