From e2c2740365b1f25beca1e174c8c5bda2950b7466 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 3 Feb 2015 00:44:46 +0100 Subject: implement api/user/create_apikey Signed-off-by: Florian Pritz --- application/controllers/api/v1/user.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'application/controllers') diff --git a/application/controllers/api/v1/user.php b/application/controllers/api/v1/user.php index 4c2e5345d..39c833d86 100644 --- a/application/controllers/api/v1/user.php +++ b/application/controllers/api/v1/user.php @@ -21,9 +21,19 @@ class user extends \controllers\api\api_controller { $this->muser->require_access("full"); return send_json_reply(\service\user::apikeys($this->muser->get_userid())); } - + public function create_apikey() { - // TODO: implement + $this->muser->require_access("full"); + $userid = $this->muser->get_userid(); + $comment = $this->input->post("comment"); + $comment = $comment === false ? "" : $comment; + $access_level = $this->input->post("access_level"); + + $key = \service\user::create_apikey($userid, $comment, $access_level); + + return send_json_reply(array( + "new_key" => $key, + )); } } -- cgit v1.2.3-24-g4f1b